xxxxxxxxxx
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/logo.png"), fit: BoxFit.cover)),
child: Scaffold(),),);
xxxxxxxxxx
if you want the image to fill the entire screen you can use a DecorationImage with a fit of BoxFit.cover.
// Learn Flutter inside VS Code at sideguide.dev/courses/flutter?ref=grepper
class BaseLayout extends StatelessWidget{
@override
Widget build(BuildContext context){
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/bulb.jpg"),
fit: BoxFit.cover,
),
),
child: null /* add child content here */,
),
);
}
}
xxxxxxxxxx
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
home: Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('Background'),
),
body: Container(
constraints: BoxConstraints.expand(),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/app_bg.jpg"),
fit: BoxFit.cover)),
child: TextField(decoration: InputDecoration(fillColor: Colors.amber,filled: true),))));
}
}