I am now working with the infinite scroll down widget of flutter. The problem is every child(item) widget's height should be different between each other.
In PagedGridView, there is a property called childAspectRatio.
This is a double type value by default 1.0
I want to make the each child widget's height would be flexible according to its original size. Is there a good way to set the childAspectRatio dynamically according to the item's original size?
If this is an impossible way, is there any other approach without using infinite scroll loading package that implements each item's height-flexible grid view with scroll loading?
How to do this?
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
final double itemWidth = size.width / 2;
double itemHeight = 0.0;
_displayItem (BuildContext context, Widget item, int index) {
double itemHeight = MediaQuery.of(context).size.height;
print(itemHeight);
return item;
}
return PagedGridView<int, Widget>(
showNewPageProgressIndicatorAsGridChild: true,
showNewPageErrorIndicatorAsGridChild: true,
showNoMoreItemsIndicatorAsGridChild: true,
pagingController: _pagingControllerForDummy,
builderDelegate: PagedChildBuilderDelegate<Widget>(
itemBuilder: (context, item, index) => _displayItem(context, item, index),
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: itemWidth / itemHeight,
crossAxisCount: 2,
),
);
}