getExtendedListDelegate method

ExtendedListDelegate getExtendedListDelegate(
  1. int childCount, {
  2. bool showNoMore = true,
})

Implementation

ExtendedListDelegate getExtendedListDelegate(
  int childCount, {
  bool showNoMore = true,
}) {
  if (extendedListDelegate != null) {
    if (extendedListDelegate
        is SliverWaterfallFlowDelegateWithFixedCrossAxisCount) {
      final SliverWaterfallFlowDelegateWithFixedCrossAxisCount delegate =
          extendedListDelegate
              as SliverWaterfallFlowDelegateWithFixedCrossAxisCount;
      return SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
        crossAxisCount: delegate.crossAxisCount,
        mainAxisSpacing: delegate.mainAxisSpacing,
        crossAxisSpacing: delegate.crossAxisSpacing,
        lastChildLayoutTypeBuilder: showNoMore
            ? extendedListDelegate!.lastChildLayoutTypeBuilder ??
                ((int index) => childCount == index
                    ? lastChildLayoutType
                    : LastChildLayoutType.none)
            : null,
        closeToTrailing: delegate.closeToTrailing,
        collectGarbage: delegate.collectGarbage,
        viewportBuilder: delegate.viewportBuilder,
      );
    } else if (extendedListDelegate
        is SliverWaterfallFlowDelegateWithMaxCrossAxisExtent) {
      final SliverWaterfallFlowDelegateWithMaxCrossAxisExtent delegate =
          extendedListDelegate
              as SliverWaterfallFlowDelegateWithMaxCrossAxisExtent;
      return SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
        maxCrossAxisExtent: delegate.maxCrossAxisExtent,
        mainAxisSpacing: delegate.mainAxisSpacing,
        crossAxisSpacing: delegate.crossAxisSpacing,
        lastChildLayoutTypeBuilder: showNoMore
            ? extendedListDelegate!.lastChildLayoutTypeBuilder ??
                ((int index) => childCount == index
                    ? lastChildLayoutType
                    : LastChildLayoutType.none)
            : null,
        closeToTrailing: delegate.closeToTrailing,
        collectGarbage: delegate.collectGarbage,
        viewportBuilder: delegate.viewportBuilder,
      );
    } else {
      return ExtendedListDelegate(
        lastChildLayoutTypeBuilder: showNoMore
            ? extendedListDelegate!.lastChildLayoutTypeBuilder ??
                ((int index) => childCount == index
                    ? lastChildLayoutType
                    : LastChildLayoutType.none)
            : null,
        closeToTrailing: extendedListDelegate!.closeToTrailing,
        collectGarbage: extendedListDelegate!.collectGarbage,
        viewportBuilder: extendedListDelegate!.viewportBuilder,
      );
    }
  }

  return ExtendedListDelegate(
    lastChildLayoutTypeBuilder: showNoMore
        ? (int index) => childCount == index
            ? lastChildLayoutType
            : LastChildLayoutType.none
        : null,
  );
}