-1

I want to use the same background image for all screen in my app, make it static so it don't move when I use navigator. Do you have an idea how to do that ?

luc
  • 1,301
  • 2
  • 14
  • 30
  • This will help: https://stackoverflow.com/questions/43822671/how-do-i-set-the-background-color-of-my-main-screen-in-flutter – FantaMagier Jun 01 '21 at 09:22

1 Answers1

0

You can define a widget with a background image and stack your desired screen on top of that.

class BackgroundPage extends StatelessWidget {
  const BackgroundPage({
    Key key,
    @required this.child,
  }) : super(key: key);

  /// The widget to display
  final Widget child;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: <Widget>[
          Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: ExactAssetImage('image.png'),
              ),
            ),
          ),
          child,
        ],
      ),
    );
  }
}
quoci
  • 2,940
  • 1
  • 9
  • 21