how can i make the headers from Custom Sticky Header stick below each other instead of overlapping in flutter?


I think I understood how the Custom Sticky Header work now, but I just can’t find where can i add the functionality to stop the headers of Sticky Header from overlapping
i would like to achieve something like in the picture below but without overlapping of the headers, i want each header to stick below each other.
Any help on where to add additional functionalities would be a huge help, thanks in advance!
image showing the overlapping sticky header

Edit: source link


Okay, The logic is simple. just add a header to your list and subitems of header to that list.

So, you can implement your requirements by using the code :

    List<Widget> _buildStickySliverListTest(ListCount sliverList) {
    var widgetList = List<Widget>();
    for (int index = 0; index <; index++) {
            automaticallyImplyLeading: false,
            title: Text("Header $index"),
            pinned: true,
            itemExtent: 50.0,
            SliverChildBuilderDelegate((BuildContext context, int index) {
              return Container(
                color: Colors.lightBlue[100 * (index % 9)],
                child: Text('Sublist item $index'),
            }, childCount:[index].length),

    return widgetList;

  Widget build(BuildContext context) {
    var list1=["a","b","c"];
    var list2=["a","b","c","d","e"];
    var list3=["a","b"];
    var list4=["a","b","c","d"];
    var data=[list1,list2,list3,list4];
    var sliverList=ListCount(data);

    return Scaffold(
      appBar: AppBar(
        title: Text("Sticky Sliver List"),
      body: CustomScrollView(
      slivers: _buildStickySliverListTest(sliverList),

Also, Create a class for ListCount as below,

class ListCount{
  List<List<String>> data;


This way you can easily build you header and sublist. implement your logic for listing and header as per your choice.

I hope this will work for your requirements.

Answered By – Jay Mungara

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *