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))),
),
]),
),
]),
));
} }
Space between only works if there's space for it to distribute. There's a few things you're doing here that's not correct.
Remove the Column that is the child of the Center widget. It's not doing anything. That should fix your problem. Then there's additional things you can do.
Set the Column in the container's size to max so it can take up the full screen and not wrap its children