
I'm trying to create a login page, and I want to make some space between the second text field and the login button , tried spaceBetween and spaceAround but didn't work
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center,
children: [
Container( padding:EdgeInsets.all(10),
color: Colors.blueGrey,
child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text("Login",style:TextStyle(fontWeight: FontWeight.bold,fontSize: 20)),
TextField(
controller: name_field,
),
TextField(
controller: password_field,
),
Container(color: Colors.blue,alignment: Alignment.center,padding: EdgeInsets.all(1),
child: TextButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return SecondScreen(
name: name_field.text, pass: password_field.text);
}));
},
child: Text("Login",style:TextStyle(color: Colors.white))),
),
]),
),
]),
));
} }
mainAxisAlignmentwill adjust child with main axis, but in your case, you are using 'Center' that make 'Column' minimum size, it mean no waster space insideColumn.To fix this, you can remove
Centeror fix height ofContainerlike thisExample: remove
Center