I wanna achieve like this pic. to simplify I created a stack that contains two Containers. i want to bottom center the small container using Align widget but its not working! it is always remaining at the top
Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: 170,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0))),
// child: Image.network(tutorImage),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: 60,
height: 60,
color: Colors.black,
),
)
],
),
For the widget's offset position, call RenderBox 's localToGlobal method whose return type is Offset . The Offset class has some properties. For getting the offset position in x and y axis, you can read the dx and dy properties respectively. The returned offset is the top left position of the widget.
But in Flutter, if you want add some extra space around a widget, then you wrap it in a Padding widget. Now to add padding, wrap the Text widget with a Padding widget. In Android Studio this can be accomplished by placing your cursor on the widget and pressing Option+Enter (or Alt+Enter in Windows/Linux).
You can use the Positioned.fill with Align inside a Stack:
Column(
children: <Widget>[
Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: 170,
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.only(bottomLeft: Radius.circular(0), bottomRight: Radius.circular(0))),
// child: Image.network(tutorImage),
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
width: 60,
height: 60,
color: Colors.black,
),
),
)
],
),
],
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With