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

SliverFillRemaining fill more than remaining space available #17444

Closed
asoseil opened this issue May 9, 2018 · 20 comments · Fixed by #33627
Closed

SliverFillRemaining fill more than remaining space available #17444

asoseil opened this issue May 9, 2018 · 20 comments · Fixed by #33627
Assignees
Labels
f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Milestone

Comments

@asoseil
Copy link

asoseil commented May 9, 2018

It seems that SliverFillRemaining fills a space with a height equal to the height of the viewport and not equal to remaining available space.

new CustomScrollView(
        slivers: <Widget>[
          new SliverToBoxAdapter(
          child: new Container(color: Colors.red,
          height: 150.0,
          )),
          new SliverFillRemaining(
            child: new Container(color: Colors.white),
          )
        ],
      )
@goderbauer goderbauer added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels May 9, 2018
@kbrz
Copy link

kbrz commented May 31, 2018

Same thing happens to me. Having CustomScrollView with SliverAppBar, SliverList using SliverChildBuilderDelegate and SliverFillRemaining results in SliverFillRemaining's height equal to viewport's height. So I can scroll until last element of the list is scrolled out of the screen.

@figengungor
Copy link

+1

@zoechi zoechi added this to the Goals milestone Oct 27, 2018
@fit-aditya
Copy link

fit-aditya commented Nov 15, 2018

I can confirm this is the behavior as of 0.11.3, any workarounds?

Edit: there is some unexpected behavior -

  1. Create a CustomScrollView with SliverAppBar and SliverFillRemaining
  2. Add a FractionallySizedBox inside SliverFillRemaining with heightFactor 0.5 and a Container with color green
  3. Scrolling the UI changes height of the FractionallySizedBox

How is scrolling adding height to the SliverFillRemaining?

@lubritto
Copy link
Contributor

@zoechi Any update ?

@aloisdeniel
Copy link

aloisdeniel commented Apr 10, 2019

Not working for me too.

After profiling the source code, it seems that the issue comes from :

aloisdeniel@54952a9#diff-85d3eb0d3e238772f866f76eab9b7acd

When replacing with scrollExtent: constraints.scrollOffset, I get the expected behaviour.

@thekeenant
Copy link
Contributor

thekeenant commented Apr 11, 2019

This helped me out: https://pub.dartlang.org/packages/sliver_fill_remaining_box_adapter
I didn't look into how it works/fixed the issue I was facing, but it seems related to the issue reported here.

@minhdtb
Copy link

minhdtb commented Apr 30, 2019

I got the same issue. Any update now?

@dnfield
Copy link
Contributor

dnfield commented May 15, 2019

Was looking at this with @chunhtai and @Piinks - it seems like changing line 127 of sliver_fill.dart to

 scrollExtent: extent,

Fixes this but breaks the nested scroll view tests. It's possible those nested scroll view tests are incorrect. @Piinks says she'll look into it a bit more.

@Piinks Piinks self-assigned this May 15, 2019
@ziakhan110
Copy link

any fix for this yet?

@Piinks
Copy link
Contributor

Piinks commented May 30, 2019

... it seems like changing line 127 of sliver_fill.dart to

 scrollExtent: extent,

Fixes this but breaks the nested scroll view tests. It's possible those nested scroll view tests are incorrect.

This appears to not only break the NestedScrollView tests, but also breaks the expected physics in regards to the iOS bounce at the top and bottom of the CustomScrollView.

When replacing with scrollExtent: constraints.scrollOffset, I get the expected behaviour.

Does seem to work for this issue. I think that the use cases for SliverFillRemaining on its own in the sample code above and within NestedScrollView have different behavior expectations.

I have a PR up now (#33627) that instead creates a flag for SliverFillRemaining to be able to specify which behavior you want from this widget. Currently, it defaults to work appropriately in this situation.

@Piinks Piinks modified the milestones: Goals, June 2019 Jun 12, 2019
@chloe722
Copy link

+1

@eliwowlol123
Copy link

This helped me out: https://pub.dartlang.org/packages/sliver_fill_remaining_box_adapter
I didn't look into how it works/fixed the issue I was facing, but it seems related to the issue reported here.

thanks, you are a g-d

@niallshaw
Copy link

I don't think this issue should be closed.

@hamishjohnson
Copy link

I'm not sure what @Piinks PR fixed here?
@dnfield solution to

seems like changing line 127 of sliver_fill.dart to

 scrollExtent: extent,

Isn't available anymore, and the issue is not related to NestedScrollViews. The issue still exists

@Piinks
Copy link
Contributor

Piinks commented Jul 13, 2020

I'm not sure what @Piinks PR fixed here?
@dnfield solution to

seems like changing line 127 of sliver_fill.dart to

 scrollExtent: extent,

Isn't available anymore, and the issue is not related to NestedScrollViews. The issue still exists

@magpiedigital I would recommend filing a new issue with a code sample that reproduces the bug you are experiencing along with the output of flutter doctor -v . Feel free to ping me on it and we can take a look! :)

@hamishjohnson
Copy link

It's the same issue as the OP and their code is all you need to reproduce the bug. Just scroll down. Perhaps I'm wrong, but my expected behavior is that it works like a sliver version of Expanded widget.

@Piinks
Copy link
Contributor

Piinks commented Jul 13, 2020

It's the same issue as the OP and their code is all you need to reproduce the bug. Just scroll down. Perhaps I'm wrong, but my expected behavior is that it works like a sliver version of Expanded widget.

The OP was solved by the introduction of SliverFillRemaining.hasScrollBody, which defaults to true. By default, SliverFillRemaining will maintain the behavior of the OP, but by using hasScrollBody: false, it is solved. There are several sample apps that demonstrate different use cases in the api documentation: https://master-api.flutter.dev/flutter/widgets/SliverFillRemaining-class.html

If you find you are still experiencing an issue, please file a new bug. Thanks! :)

@dvirgiln
Copy link

dvirgiln commented Feb 5, 2021

I opened a similar issue. It seems that using TabBar and setting hasScrollBody:false does not make it to work.

#75517

@dvirgiln
Copy link

dvirgiln commented Feb 5, 2021

@Piinks could you have a look to the ticket I opened. It is quite related.

Thanks

@github-actions
Copy link

github-actions bot commented Aug 6, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.