I'm trying to bottom-center a widget at the bottom of a Column, but it keeps aligning to the left.
return new Column(
new Stack(
new Positioned(
bottom: 0.0,
new Center(
new Container(),
),
),
),
);
The existence of the Positioned forces the Container to the left, instead of centering. Removing the Positioned, however, puts the Container in the middle-center.
Align is the way to go is you have only one child.
If you have more, consider doing something like this :
return new Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
//your elements here
],
);
1) You can use an Align widget, with FractionalOffset.bottomCenter
.
2) You can also set left: 0.0
and right: 0.0
in the Positioned
.
I have used this approach,
What i want is, A layout
always in bottom but whenever Keyboard pops-up that layout
also comes over it
body: Container(
color: Colors.amber,
height: double.maxFinite,
child: new Stack(
//alignment:new Alignment(x, y)
children: <Widget>[
new Positioned(
child: myWidget(context, data.iconName, Colors.red),
),
new Positioned(
child: new Align(alignment: FractionalOffset.bottomCenter,child: myWidget(context, data.iconName, Colors.green)),
)
],
),
),