fluttercommunity / flutter_sticky_headers

Flutter Sticky Headers - Lets you place "sticky headers" into any scrollable content in your Flutter app. No special wrappers or magic required. Maintainer: @slightfoot
https://pub.dev/packages/sticky_headers
MIT License
1.1k stars 129 forks source link

Between two sticky headers is padding #46

Closed aytoku closed 2 years ago

aytoku commented 3 years ago

Hello, between two sticky headers is padding and i can't remove it? Can you explain me how can i fix it or this is a bug? image

Carmelo992 commented 2 years ago

I had the same problem, I added a stickyHeader in a list view and during the scroll there was the same transparent line above the header.

I can suggest the workaround that I used to "solve" this issue. It is a truly bad workaround, but it works.

I wrapped the content widget inside a stack where the first item inside the children list is the widget that you want to display, then I added another child that is a Positioned with a white container and I moved it during the scroll to cover that line.

Here is a snapshot of the code:

StickyHeader(
  header: buildTabBar(),
  content: Stack(
    children: [
      [WIDGET],
      AnimatedBuilder(
        animation: scrollOffset,
        builder: (_, __) {
          return Positioned(
            top: scrollOffset.value >= 200 ? scrollOffset.value - 200 : -20,
            left: 0,
            right: 0,
            child: Container(color: Colors.white, height: 20)
          );
      })
    ],
  ),
)

scrollOffset is a ValueNotifier connected to the list view controller

_controller.addListener(() {
  scrollOffset.value = _controller.position.pixels;
});

200 is a magic number that I found during the test, it is the offset when the line starts to appear

slightfoot commented 2 years ago

Fixed as-of v0.3.0.