assetsGridBuilder method

Widget assetsGridBuilder(
  1. BuildContext context,
  2. double extent,
  3. ScrollController scrollController,
  4. bool scrollLock,
  5. double footerHeight,
  6. Map<String, double> displayAssets,
)

The primary grid view builder for assets

Implementation

Widget assetsGridBuilder(BuildContext context, double extent, ScrollController scrollController, bool scrollLock, double footerHeight, Map<String, double> displayAssets){

  //Height of the screen
  var height = MediaQuery.of(context).size.height;

  //Width of the screen
  var width = MediaQuery.of(context).size.width;

  List<double> urlRatio = displayAssets.values.toList();

  return StaggeredGridView.countBuilder(
    controller: scrollController,
    physics: scrollLock ? NeverScrollableScrollPhysics() : BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
    mainAxisSpacing: 1,
    crossAxisSpacing: 1,
    padding: EdgeInsets.only(bottom: footerHeight + MediaQueryData.fromWindow(window).viewInsets.bottom),
    itemCount: displayAssets.length,
    scrollDirection: Axis.vertical,
    crossAxisCount: 2,
    itemBuilder: (context, i){
      return assetItemBuilder(displayAssets.keys.elementAt(i), displayAssets, i);
    },
    staggeredTileBuilder: (int index) => StaggeredTile.extent(1, (width*0.5)/urlRatio[index] - 15),
  );
}