Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for adding Sliver into an IndexedStack #82

Closed
alexda12 opened this issue Aug 10, 2023 · 1 comment
Closed

Workaround for adding Sliver into an IndexedStack #82

alexda12 opened this issue Aug 10, 2023 · 1 comment

Comments

@alexda12
Copy link

Hi, firstly - thanks for such a fantastic, easy to use sliver package. I use this extensively and its really allowed me to create with ease sliver related functionality.

I'm now finding however a limitation - maybe you can provide a potential workaround. I have a Tab where I have 3 tabviews, the contents of each tabview is a Sliver. Prior to placing each tabview in a sliver, I used an IndexedStack which basically promoted the currently active tabs data, thus making it current and displaying the List. This works perfectly ... however, once I switched to using a SliverList for each of the 3 tabviews, I found that the IndexedStack did not permit a SliverList to be a direct child.

I therefore tried to provide a workaround , such as :

return SliverStack (children: [
      SliverOffstage(
        offstage: tabIndex == 0 ? false : true,
        sliver: SliverIgnorePointer(
          ignoring: tabIndex == 0 ? false : true,
          sliver: SliverVisibility(
            maintainState: true,
            sliver: sliverListData1,
            visible: tabIndex == 0 ? true : false,
          ),
        ),
      ),
      SliverOffstage(
        offstage: tabIndex == 1 ? false : true,
        sliver: SliverIgnorePointer(
          ignoring: tabIndex == 1 ? false : true,
          sliver: SliverVisibility(
            maintainState: true,
            sliver: sliverListData2,
            visible: tabIndex == 1 ? true : false,
          ),
        ),
      ),
      SliverOffstage (
        offstage: tabIndex == 2 ? false : true,
        sliver: SliverIgnorePointer(
          ignoring: tabIndex == 2 ? false : true,
          sliver: SliverVisibility (
            maintainState: true,
            sliver: sliverListData3,
            visible: tabIndex == 2 ? true : false,
          ),
        ),
      ),
    ]);

As you can see, I add all three list views on top of each other and only show the data for the active tab. That works perfectly. The issue I have however is that even though we only show 1 active SliverList at a time, the hidden SliverLists appear to still receive events (and thus rebuild) when we scroll the primary (active) SliverList.

I was playing around with using :

Offstage, Opacity, Visibility, Absorbing, Ignore etc widgets to try and prevent the hidden Widgets from receiving and rebuilding but since they are placed on a SliverStack (and no SliverIndexedStack) they still receive events and thus cause further issues.

So, to conclude - is there any plans for a SliverIndexStack or do you know of any way to accomplish the above ?

TIA.

@Kavantix
Copy link
Owner

Kavantix commented Nov 8, 2023

I'm not planning on adding new features myself in the nearby future.

But I do have a draft PR open which does something similar

@Kavantix Kavantix closed this as not planned Won't fix, can't repro, duplicate, stale Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants