flutter_sticky_header icon indicating copy to clipboard operation
flutter_sticky_header copied to clipboard

Seeking Clarification on Sticky Header Scroll Notifications

Open JasonYHZ opened this issue 2 years ago • 0 comments

Hello,

I am currently using the flutter_sticky_header package in my project and I have a question regarding its functionality.

I am interested in receiving notifications when the sticky header scrolls out of the viewport. I understand that I can use a StickyHeaderController to listen to the current sticky header's scroll offset. However, I am not entirely sure how to determine when the header is out of the viewport using this controller.

Here is a snippet of my current implementation:

final controller = StickyHeaderController();


CustomScrollView(
slivers:[
// index 1
SliverStickyHeader(
  controller: controller,
  header: Text('Header'),
  sliver: SliverList(...),
),
// index 1
SliverStickyHeader(
  controller: controller,
  header: Text('Header'),
  sliver: SliverList(...),
),
]
)

controller.addListener(() {
});

In the above code, I am using the pinned property of the offset to determine if the header is out of the viewport. Is this the correct approach? If not, could you please provide some guidance on how to correctly implement this functionality?

Thank you for your time and assistance.

JasonYHZ avatar Jan 01 '24 03:01 JasonYHZ