-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add a widget similar to SliverFillRemaining but allows for a minimum scroll amount #22
Comments
I cannot reproduce your issue. |
Parent widget would be: class ExampleParentScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
extendBody: true,
backgroundColor: Themes.white,
bottomNavigationBar: const NavigationWidget(),
body: CustomScrollView(
physics: BouncingScrollPhysics(),
slivers: <Widget>[
const ExampleAppBarWidget(),
const ExampleWidget()
],
),
);
},
}
And ExampleAppBarWidget: class ExampleAppBarWidget extends StatelessWidget {
static const double collapsedHeight = 57.0;
static const double expandedHeight = 465.0;
const ExploreAppBarWidget();
@override
Widget build(BuildContext context) {
return SliverPersistentHeader(
pinned: true,
delegate: _SliverAppBarDelegate(
minHeight: collapsedHeight + MediaQuery.of(context).padding.top,
maxHeight: expandedHeight + MediaQuery.of(context).padding.top),
);
}
}
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
final double minHeight;
final double maxHeight;
_SliverAppBarDelegate({
@required this.minHeight,
@required this.maxHeight,
});
@override
double get minExtent => minHeight;
@override
double get maxExtent => max(maxHeight, minHeight);
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(
color: Colors.red
);
}
@override
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
return false;
}
} |
Now Imagine scrolling up so the appbar collapses: the red gets smaller, and the blue gets proportionally bigger. In 1.0.9 that was the behaviour if you didn't specify height to the Container (or SizedBox). In 1.1.10+1 the blue part wont resize so the appbar is not collapsable. You could give a scrollbody to the SliverFillRemaining but then the blue part would be viewport height, and the green list items would be scrollable offscreen. The intended behaviour is that if I have less items in the list than would fill the screen, then SliverFillRemaining would fill the missing part so the appbar is fully collapsable (otherwise the appbar would only be collapsable to the extent I have list items). The use case would be a situation where I can add and remove items to and from the list. Or better example, I wouldn't want a situation where I only see partly expanded or collapsed appbar assuming I'm showing different content whether it is fully expanded or collapsed. |
Sadly I must tell you that the behaviour 0.1.9 had was actually incorrect. I do actually have an adapted version of SliverFillRemaining in my private code (it's not open source ready) that allows you to specify a minimum amount of scroll that the SliverFillRemaining should provide. |
I have emailed you the current version of the SliverFillRemainingWithMinimum widget |
how did this end? |
@martipello it wasnt what he needed, feel free to open an issue if you’re running into something |
Changes from 0.1.9 to 0.1.10 break passing constraints to children:
In 0.1.9 the SliverFillRemaining correctly filled the remaining space in the list if there are not enough items in the list to allow for the Multisliver to expand and fill the viewport in a CustomScrollView that already has a preceding flexible SliverAppBar. Or more succinctly 0.1.10 changes caused the child of SliverFillRemaining in MultiSliver to always have a height of 0.
The text was updated successfully, but these errors were encountered: