sliverScrollView function

Widget sliverScrollView({
  1. required List<Widget> children,
  2. ScrollController? controller,
  3. Key? key,
})

Creates a CustomScrollView from a list of widgets, automatically converting non-sliver widgets into SliverToBoxAdapter.

children is the list of widgets to display. controller optionally controls scrolling. key optionally assigns a key to the scroll view.

Implementation

Widget sliverScrollView({
  required List<Widget> children,
  ScrollController? controller,
  Key? key,
}) {
  return CustomScrollView(
    controller: controller,
    key: key,
    slivers:
        children
            .map(
              (s) =>
                  s is SliverList || s is SliverGrid || s is SliverPadding
                      ? s
                      : s.sliver(), // Wrap non-slivers into SliverToBoxAdapter
            )
            .toList(),
  );
}