build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds the Collection widget based on the provided configuration.

This method determines the appropriate rendering strategy by examining the configuration:

This adaptive approach ensures compatibility with both sliver and non-sliver layouts, optimizing performance and preventing layout errors in scrollable parents.

Implementation

@override
Widget build(BuildContext context) {
  if (builder != null) {
    if (customBuilder) {
      return MultiSliver(
        children: List.generate(childCount!, (i) => builder!(context, i)),
      );
    }

    return SListView.builder(builder: builder);
  }

  if (children.any((element) =>
      element is Section ||
      element is Collection ||
      element.isSliver(context))) {
    return MultiSliver(children: children);
  } else {
    return SListView(
      children: children,
    );
  }
}