'How to make background image to be fixed in flutter

I'm using an image as a background, and it looks good until I use the keyboard, how to solve that?

before the keyboard is shown and that's after the keyboard is shown

Container(
          width: double.infinity,
          height: double.infinity,
          decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage(
                    'images/joker.jpg',
                  ),
                  fit: BoxFit.fill)),


 


Solution 1:[1]

Try to add this to Scaffold of this widget:

Scaffold(
   resizeToAvoidBottomInset: false,
)

Solution 2:[2]

You can do that by using The Stack widget, it uses the children[] widget. but make sure to set the Image widget at the top of the list (so that the image can appears behind the form).

You can use this structure:

Stack( 
       children:[ 
                  Image(),    
                  SingleChildScrollView( 
                                        child: 
                                              YourFormWidgetHere()
                                        )
                 ]
       )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amir
Solution 2