Cannot Center Column Widget
For centering vertically,
Center(
child:Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ ... ],
)
)
Center vertically
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ ... ],
)
Center horizontally
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ ... ],
)
But if the column is hugging its content then just wrap it in a Center widget
Center(
child: Column(
children: <Widget>[ ... ],
),
)
Add MainAxisAlignment.center
and remove Expanded
class SignIn extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: Padding(
padding: EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
'SignIn Screen',
style: TextStyle(fontSize: 26.0),
),
Padding(
padding: EdgeInsets.only(top: 30.0),
),
TextField(
maxLength: 25,
decoration: InputDecoration(
hintText: 'Enter username',
),
),
TextField(
maxLength: 25,
decoration: InputDecoration(
hintText: 'Enter password',
),
),
RaisedButton(
child: Text('SignIn'),
onPressed: _signIn,
),
],
),
),
);
}