I would like to make a container to adapt to full size of the screen (with min height and width) no matter how the user resize the window.
But now I have to hard code the dimension of the container, otherwise error returns:
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
Please help to tell how to make the layout much like this:
Widget build(BuildContext context) {
return Container(
width: 1000,
height: 600,
decoration: BoxDecoration(
border: Border.all(color: Colors.blueAccent),
),
child: Column(
children: [
Expanded(
child: ListView.builder(
itemCount: dataList.length,
itemBuilder: (BuildContext context, int index) {
return dataCard(context, dataList, index);
}),
),
SizedBox(height: 20),
TextButton(
onPressed: () {},
child: Text('add'),
)
],
),
);
}
}
Widget dataCard(context, dl, i) {
return Row(
children: [
Expanded(
flex: 1,
child: Text(dl[i].id.toString()),
),
Expanded(
flex: 4,
child: Text(dl[i].chinesename),
),
Expanded(
flex: 4,
child: Text(dl[i].englishname),
),
Expanded(
flex: 1,
child: TextButton(
onPressed: () {},
child: Text('Edit'),
),
),
Expanded(
flex: 1,
child: TextButton(
onPressed: () {},
child: Text('Delete'),
),
),
],
);
}
3
Answers
try using this code
Use the code below instead.
You should not give the container height and width static. Give it like a dynamic;
You can multiply these values according to the values you want.