-
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
Wrong calculations for multiple pinned SliverPersistentHeader inside a NestedScrollView #62
Comments
Hi @papmodern thanks for opening an issue! In 0.2.8 I fixed #56 which was also related to NestedScrollView, could you test with 0.2.7 to see if that’s what caused this? |
It is working fine with This is a sample code to demonstrate the problem: class SampleWidget extends StatelessWidget {
const SampleWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverOverlapAbsorber(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: MultiSliver(
children: [
SliverAppBar(
pinned: true,
title: Text('First AppBar'),
expandedHeight: 100,
collapsedHeight: 60,
),
SliverAppBar(
pinned: true,
title: Text('Second AppBar'),
expandedHeight: 200,
collapsedHeight: 60,
backgroundColor: Colors.red,
),
SliverAppBar(
pinned: true,
title: Text('Third AppBar'),
expandedHeight: 200,
collapsedHeight: 60,
backgroundColor: Colors.yellow,
),
],
),
),
];
},
body: ListView.builder(
itemBuilder: (c, i) => ListTile(
title: Text('Item $i'),
),
),
),
),
);
}
}` |
@papmodern are you sure that the problem that existed in #56 is not occurring for you before 0.2.8 (because in my testing it does). Either way I would recommend not to use a NestedScrollView, you can implement the example above without it. Note that the behaviour there is also not what you would like to have. class SampleWidget extends StatelessWidget {
const SampleWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
pinned: true,
title: Text('First AppBar'),
expandedHeight: 100,
collapsedHeight: 60,
),
SliverAppBar(
pinned: true,
title: Text('Second AppBar'),
expandedHeight: 200,
collapsedHeight: 60,
backgroundColor: Colors.red,
),
SliverAppBar(
pinned: true,
title: Text('Third AppBar'),
expandedHeight: 200,
collapsedHeight: 60,
backgroundColor: Colors.yellow,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(c, i) => ListTile(
title: Text('Item $i'),
),
),
),
],
),
),
);
}
} |
Also, |
@Kavantix In the real app I faced the problem, I have tab bar and tab bar view and each tab has its own scrollview. So I have to use NestedScrollView. The code I wrote for you is only for demonstrating the problem. Even SliverOverlapAbsorber is not necessary here and if you remove just this one, everything works fine. |
I had a section in my app which contains a appbar a top section and tab bar which all of them are implemented with
NestedScrollView
andMultiSliver
. It was working fine but it came up problematic after I removed mypubspec.lock
file.Recent problem:
Previously correct behavior
Therefore I realized this feature of the lib is corrupted from version
0.2.5
to0.2.8
I'm working on Flutter
2.10.5
I used the lib with
0.2.5
exact version asdependency_overrides
and its working correctly now. But I wanted to inform you about this new bugI can describe the wrong behavior in this way. Whenever you add more than one
SliverPersistentHeader
orSliverAppBar
withpinned: true
property, the first one works fine, but the rest of the slivers can't understand the position and they don't receiveshrinkOffset
changes. Also the body of theNestedScrollView
goes behind these widgets(The ones after the first pinned widget).The text was updated successfully, but these errors were encountered: