Trying to add background image for widget in flutter app but i do not know how to add it. I am new for flutter.So, If Anyone knows please help to find the solutions.
login.dart:
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
const SizedBox(
height: 1,
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Image.asset("images/logo.png"),
),
const SizedBox(height: 10),
TextField(
.........
),
const SizedBox(height: 20),
TextField(
..........
),
const SizedBox(height: 20),
TextField(
..........
)
],
),
),
),
);
}
CodePudding user response:
Wrap the SingleChildScrollView with a Container and add decoration
Scaffold(
resizeToAvoidBottomInset : false,
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image : DecorationImage(
image: AssetImage('imagePathHere'),
)
),
child: SingleChildScrollView(
)
)
)