Search code examples
flutterdartflutter-state

Can someone explain what are Slivers and Delegates in flutter and why to use them?


"Link to code"

I was following the Flutter State Management tutorial and came across this.

Please explain what are Slivers, Delegates. Especially this part that I have attached.

class MyCatalog extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          _MyAppBar(),
          SliverToBoxAdapter(child: SizedBox(height: 12)),
          SliverList(
            delegate: SliverChildBuilderDelegate(
                (context, index) => _MyListItem(index)),
          ),
        ],
      ),
    );
  }
}

Solution

  • I can say it briefly: Slivers special animation area. Slivers You have a lot of option slivers widget also normal widgets (SliverGrid => GridView). Sliver scroll affects the biggest difference in normal listview.

    Slivers ok, so what is ChildDelegate?

    Delegate: Slivers draw type. Maybe sometimes set array builder function need. SliverListDelegate Delagete needs children array also SliverListBuilderDelagate return builder function and children count. Child Delegate