YRefreshListView<T> function

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

Implementation

Widget YRefreshListView<T>({
  required List<T> models,
  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,
  bool reverse = false,
}) {
  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: ListView.builder(
        padding: padding,
        primary: false,
        shrinkWrap: true,
        reverse: reverse,
        itemCount: models.length,
        itemBuilder: (context, index) => itemBuilder(context, index, models[index]),
      ),
    ),
  );
  return scrollbar ? Scrollbar(child: easyRefresh) : easyRefresh;
}