I have a Layout with 2 Columns (see image). Now i have a List<Widget> and i want to place theses Widgets (e.g. Text Widgets) in the two Columns. First i want to fill Column 1 and when there is no more space for another Text Widget in this Column, I want to start filling Column 2. How can i do this?
The LayoutBuilder widget is used to determine the available height within the parent Column. If the available height is greater than the initial height of the first
Column(
children: [
// First Column
Container(
color: Colors. blue,
height: 300, // Initial height of the first column
child: Column(
children: [
// Widgets in the first column
// ...
],
),
),
// Second Column (conditionally displayed)
LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxHeight > 300) {
// Display widgets in the second column
return Container(
color: Colors. red,
child: Column(
children: [
// Widgets in the second column
// ...
],
),
);
} else {
return Container(); // Empty container if the second column is not needed
}
},
),
],
),
);
2
Answers
I found a Solution with a ListView Builder. But Wrap or maybe the LayoutBuilder from the comments above would certainly also work.
The LayoutBuilder widget is used to determine the available height within the parent Column. If the available height is greater than the initial height of the first