YRefreshGridView<T> function

Widget YRefreshGridView<T>({
  1. required List<T> models,
  2. required SliverGridDelegate gridDelegate,
  3. dynamic onRefresh()?,
  4. required dynamic itemBuilder(
    1. BuildContext context,
    2. int index,
    3. T model
    ),
  5. ScrollController? scrollController,
  6. Header? header,
  7. Footer? footer,
  8. dynamic onLoadMore()?,
  9. dynamic bottomBouncing = true,
  10. dynamic scrollbar = true,
  11. EdgeInsets padding = EdgeInsets.zero,
})

Implementation

Widget YRefreshGridView<T>({required List<T> models, required SliverGridDelegate gridDelegate, Function()? onRefresh, required Function(BuildContext context, int index, T model) itemBuilder, ScrollController? scrollController, Header? header, Footer? footer, Function()? onLoadMore, bottomBouncing = true, scrollbar = true, EdgeInsets padding = EdgeInsets.zero}) {
  var easyRefresh = EasyRefresh(
    onRefresh: onRefresh != null ? () => onRefresh() : null,
    onLoad: onLoadMore != null ? () => onLoadMore() : null,
    bottomBouncing: bottomBouncing,
    scrollController: scrollController,
    header: header ?? (onRefresh != null ? BezierCircleHeader(backgroundColor: YConfig.themeColor.withOpacity(0.1), color: YConfig.themeColor) : null),
    footer: footer ?? (onLoadMore != null ? BallPulseFooter(backgroundColor: YConfig.themeColor.withOpacity(0.1), color: YConfig.themeColor, enableInfiniteLoad: false) : null),
    child: Container(
      constraints: const BoxConstraints(minHeight: 300),
      child: GridView.builder(
        padding: padding,
        primary: false,
        shrinkWrap: true,
        gridDelegate: gridDelegate,
        itemCount: models.length,
        itemBuilder: (context, index) => itemBuilder(context, index, models[index]),
      ),
    ),
  );
  return scrollbar ? Scrollbar(child: easyRefresh) : easyRefresh;
}