I’m building a Flutter app where I have a dynamic grid of elements that changes based on screen size. The grid elements are also expandable, meaning their size can change at runtime. I achieved my wanted layout; however, I’m experiencing performance issues when there are a large number of elements — the layout becomes laggy and unresponsive. Here is an Image of my (wanted) layout:
Here’s the current layout implementation:
LayoutBuilder(
builder: (context, constraints) {
// Determine the number of columns based on the width
int crossAxisCount = AppDimensions.getCrossAxisCount(constraints.maxWidth);
double itemWidth = (constraints.maxWidth - (crossAxisCount - 1) * 10) / crossAxisCount;
return Wrap(
spacing: 10,
runSpacing: 10,
children: provider.polizzenList.map((polizze) {
return Container(
width: itemWidth,
child: PolizzenCard(
polizze: polizze
),
);
}).toList(),
);
},
),
1
I was able to achieve the wanted layout by using the package dynamic_height_grid_view. This seems to also be really efficient in performance.