Reputation: 593
How can I position widgets correctly?
I supposed the positioning should be by some template and not by the eye.
Lets say i want the white square will be in the top center of the black container, half inside the black container and half outside, How can i do this?
The code:
Positioned(
top: 80,
right: 30,
left: 30,
child: Container(
height: 200,
width: 400.0,
color: Colors.black,
child: Column(
children: <Widget>[],
),
),
),
Positioned(
top: 40,
child: Container(
height: 100.0,
width: 100.0,
color: Colors.white,
),
),
Upvotes: 0
Views: 48
Reputation: 146
You can try like this
Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
top: 80,
right: 30,
left: 30,
child: Container(
height: 200,
width: 400.0,
color: Colors.black,
child: Column(
children: <Widget>[],
),
),
),
Positioned(
top: 40,
child: Container(
height: 100.0,
width: 100.0,
color: Colors.white,
),
),
],
)
Upvotes: 1