How to add an image as background image in Flutter page/activity

To add an image as background image in Flutter we can simply add the following code:-

class FlutterPage extends StatelessWidget{
  Widget build(BuildContext context){
    return Scaffold(
      body: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage("assets/images/jpg/image.jpg"),
            fit: BoxFit.cover,
        child: null,

In the above code we use a Container() inside the Scaffold widget which gives us many customization options, one of which is decoration: parameter in which we will supply the AssetImage which will give the following result:-

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.