To add an image as background image in Flutter we can simply add the following code:-
class FlutterPage extends StatelessWidget{
@override
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:-
