Reputation: 7156
I need to add padding (i.e. a space from screen edgess) for the first two widgets in a body column.
Scaffold(
body: Column(
children: [
// need to add padding for the next two widgets
Container(
child: Expanded(
child: Column(...),
),
),
Row(...),
// until here
Container(
child: Expanded(
child: Column(...
),
),
),
],
),
);
I tried to wrap them in a column again, but that gives the error:
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
I guess the problem is in wrapping the expanded column with new column. How to make that?
Upvotes: 0
Views: 790
Reputation: 337
Bro, you need to wrap your first Column with Container first, or with SizedBox. The requirement is that you cannot set Column within unbounded Width or Height. Otherwise, it will give an error. So set it up first, and set the Expanded inside it.
Upvotes: 0
Reputation: 111
You need to wrap that newly created Column with another Expanded widget.
Scaffold(
child: Column(
children: [
Expanded(
child: Container(
child: Column(
children: [
Container(
child: Expanded(
child: Column(...),
),
),
Row(...),
],
),
),
),
...
Upvotes: 1
Reputation: 2419
margin inside Container does what you want example
Container(
margin: EdgeInsets.only(
left: 10),
child:....
)
Upvotes: 0