flutterdartbackground-imagescreen

Is there a way to add a background image to a flutter app widescale?


I want to add an image as a background to all of my screens in the app built with Flutter. Is there any possible way of adding such a background image since there are no properties provided in Flutter's ThemeData class?


Solution

  • A quick way to achieve that is to create a custom widget that you could call ScaffoldImage and which will contain the following code

    return Scaffold(
      body: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage("assets/images/your_background.png"),
            fit: BoxFit.cover,
          ),
        ),
        child: Container() //Your child here
        )
    );