letsar / flutter_sticky_header

Flutter implementation of sticky headers for sliver
MIT License
907 stars 174 forks source link

How to implement nested SliverList? #66

Open erfanium opened 3 years ago

erfanium commented 3 years ago

First I use this example from here: https://github.com/letsar/flutter_sticky_header/blob/master/example/lib/examples/mix_slivers.dart

Instead of hard-coded _StickyHeaderList in build method: https://github.com/letsar/flutter_sticky_header/blob/ea97f5455a7eb52899a15cd9aed0b79286648963/example/lib/examples/mix_slivers.dart#L12-L35

I want to use another ListView like:

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      title: 'List Example',
      slivers: [
        SliverAppBar(
          backgroundColor: Colors.orange,
          title: Text('SliverAppBar'),
          automaticallyImplyLeading: false,
          pinned: true,
        ),
        SliverToBoxAdapter(
          child: Container(
            height: 50,
            color: Colors.red,
          ),
        ),
        SliverList(
          delegate: SliverChildBuilderDelegate(
            (context, i) => ListTile(
              leading: _StickyHeaderList(),
            ),
            childCount: 6,
          ),
        ),
      ],
    );
  }
}

But I get this error:

The following assertion was thrown building _StickyHeaderList:
A RenderRepaintBoundary expected a child of type RenderBox but received a child of type
RenderSliverStickyHeader.

How can I do that?

letsar commented 2 years ago

What do you want to achieve exactly? Here you provide a Sliver to the leading of the ListTile, that's why there is an error.

erfanium commented 2 years ago

@letsar

What do you want to achieve exactly?

Good question, obviously I don't remember what I wanted after a year :)