Reputation: 1295
This is my code to print the session gone inside my flutter app
else if (!snapshot.hasData && snapshot.hasError) {
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
const Text('Session TimeOut, Log back in to continue'),
RaisedButton(
onPressed: () {
Navigator.of(context).pushReplacement(
CupertinoPageRoute(
builder: (_) => LoginPage(),
),
);
},
child: const Text('LOG IN'),
),
],
),
),
);
}
It is coming like this
I want the alert messaged Should come at the center of the screen, Any idea how to fix this
Upvotes: 0
Views: 747
Reputation: 535
Column height is set to max
by default. It means that it expand to the full screen height, so Center does not do anything with it.
Also Column
aligns its children to the top-center by default.
You have two options:
mainAxisSize: MainAxisSize.min
, to your Column, and Center will workmainAxisAlignment: MainAxisAlignment.center
to your ColumnUpvotes: 1
Reputation: 2089
you need to add to Column
mainAxisSize: MainAxisSize.min,
Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Session TimeOut, Log back in to continue'),
RaisedButton(
onPressed: () {
Navigator.of(context).pushReplacement(
CupertinoPageRoute(
builder: (_) => LoginPage(),
),
);
},
child: const Text('LOG IN'),
),
],
),
),
);
Upvotes: 1