Set Background image in Flutter

If you use a Container as the body of the Scaffold, its size will be accordingly the size of its child, and usually that is not what you want when you try to add a background image to your app.

@override
Widget build(BuildContext context) {
  return new Scaffold(
    body: new Stack(
      children: <Widget>[
        new Container(
          decoration: new BoxDecoration(
            image: new DecorationImage(image: new AssetImage("images/background.jpg"), fit: BoxFit.cover,),
          ),
        ),
        new Center(
          child: new Text("Hello background"),
        )
      ],
    )
  );
}

Flutter create a circle Icon.

Today we are going to create a circle icon using flutter.

Circle Icon

For this example we will crate a state less widget in flutter.

import 'package:flutter/material.dart';

class CircleIcon extends StatelessWidget {

   finalIconDataicon;
   finaldoubleiconSize;
   finalVoidCallbackonPressed;

   constCircleIcon({
       Key? key,
       requiredthis.icon,
       this.iconSize = 25.0,
       requiredthis.onPressed,

   }) : super(key: key);

   @override

   Widgetbuild(BuildContextcontext) {

   return Container(
        margin: constEdgeInsets.all(8.0),
        decoration: BoxDecoration(
           color: Colors.grey[200],
           shape: BoxShape.circle
        ),

        child: IconButton(
          onPressed: onPressed,
          icon: Icon(icon),
          color: Colors.black,
          iconSize: iconSize,
       ),
    ); //container
  }
}

Here in this widget iconSize is optional and icon and event is required. We can use this widget like below

import ‘../widgets/circle_icon.dart’;

CircleIcon(
      icon: Icons.person_outline, 
      onPressed: () {  },
),