buildScrollViewWithWrapper method Null safety

Widget buildScrollViewWithWrapper(
  1. BuildContext context,
  2. dynamic scrollables,
  3. Widget? headerSliver,
  4. PlatformLayoutInfo layoutInfo,
  5. {SliverWrapper sliverWrapper = sameWidget,
  6. bool shrinkWrap = false}
)

Implementation

Widget buildScrollViewWithWrapper(
    BuildContext context,
    final dynamic scrollables,
    Widget? headerSliver,
    PlatformLayoutInfo layoutInfo,
    {SliverWrapper sliverWrapper = sameWidget,
    bool shrinkWrap = false}) {
  var psc = PrimaryScrollController.of(context);
  var msc = ModalScrollController.of(context);
  var scroller = msc ?? psc;
  if (scrollables is CustomScrollView ||
      scrollables is NestedScrollView ||
      widget.useBody == true) {
    _verifyNoHeader(headerSliver);
    return scrollables as Widget;
  } else if (scrollables is StreamBuilder) {
    return scrollables;
  } else if (scrollables is Widget) {
    if (scroller?.hasClients == true) {
      scroller = null;
    }
    return CustomScrollView(
      controller: widget.scroller ?? scroller,
      shrinkWrap: shrinkWrap,
      physics: scroller == null
          ? AlwaysScrollableScrollPhysics()
          : ModalScrollPhysics(),
      slivers: [
        if (headerSliver != null) headerSliver,
        scrollables,
      ],
    );
  } else {
    if (scroller?.hasClients == true) {
      scroller = null;
    }
    return CustomScrollView(
      controller: widget.scroller ?? scroller,
      shrinkWrap: shrinkWrap,
      physics: scroller == null
          ? AlwaysScrollableScrollPhysics()
          : ModalScrollPhysics(),
      slivers: [
        if (headerSliver != null) headerSliver,
        if (scrollables is List<Widget>)
          for (var sliver in scrollables) sliverWrapper(sliver),
      ],
    );
  }
}