1

enter image description hereCurrently I'm showing a CustomScrollView inside a bottomSheet.

CustomScrollView(
      controller: scrollController,
      slivers: [
        SliverPersistentHeader(
          pinned: true,
          delegate: MonthViewHeader(widget.weekDays),
        ),
        SliverList(
          delegate: SliverChildBuilderDelegate((context, index) {
            return MonthView(
                index == 0 ? widget._today : Jalali(widget._today.year, widget._today.month, 1).addMonths(index),
                index != 0,
                selectedDate,
                (DateTime date) => {
                      setSheetState(() {
                        selectedDate = date;
                        widget.onDateChange(date);
                      })
                    });
          }),
        )
      ],
    )

SliverPersistentHeader stays on top of the list on scroll and SliverList scrolls beneath it.
I want to check which item index is being entered/exited view on scroll. I want to know that so I can change my SliverPersistentHeader text.
One approach would be to calculate scrollOffset and give each item static height.
But that's not very optimal since item 0 of SilverList might have a smaller height so I can give it fixed height.
Is there any way to detect item entering/exiting view inside SilverList?

dev-aentgs
  • 1,218
  • 2
  • 9
  • 17
Mehrdad Shokri
  • 1,974
  • 2
  • 29
  • 45

1 Answers1

0

I would recommend checking out this plugin:

flutter_sticky_header

It seems that is exactly what you are looking for.

Vitor
  • 762
  • 6
  • 26
  • Nope, I have just one header, and its text is being updated. The provided library makes multiple headers and sticks the most recent item's header – Mehrdad Shokri Jul 14 '20 at 15:07