Comments (5)
Sorry for the late response but good catch!
I believe that solution is indeed correct but will have to do a little more testing in the weekend.
from sliver_tools.
The bug seems to be fixed with this patch :
index 02a3394..2aa7405 100644
--- a/lib/src/rendering/multi_sliver.dart
+++ b/lib/src/rendering/multi_sliver.dart
@@ -213,7 +213,7 @@ class RenderMultiSliver extends RenderSliver
layoutOffset += childParentData.geometry.layoutExtent;
hasVisualOverflow =
hasVisualOverflow || childParentData.geometry.hasVisualOverflow;
- maxScrollObstructionExtent =
+ maxScrollObstructionExtent +=
childParentData.geometry.maxScrollObstructionExtent;
visible = visible || childParentData.geometry.visible;
if (childParentData.geometry.cacheExtent != 0.0) {
from sliver_tools.
From my testing the change does seem to improve some scenarios, however your test scenario provided in the original comment still behaves weirdly.
However, that is probably just because of the NestedScrollView.
from sliver_tools.
Ok the weird behaviour that is left is because SliverPersistentHeader
doesnt handle overlap correctly (see flutter/flutter#91256)
from sliver_tools.
You are right, in fact, the fix work if SliverAppBar is first. I inverted the SliverAppBar with SliverPinnedHeader, my mistake
Here is the code that reproduce the problem and the fix of the PR which works fine without weird behavior.
import 'package:flutter/material.dart';
import 'package:sliver_tools/sliver_tools.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatelessWidget(),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final List<String> tabs = <String>['Tab 1', 'Tab 2'];
return DefaultTabController(
length: tabs.length, // This is the number of tabs.
child: Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverOverlapAbsorber(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: MediaQuery.removePadding(
context: context,
removeBottom: true,
child: MultiSliver(
children: [
SliverAppBar(
title: const Text('Books'),
pinned: true,
expandedHeight: 150.0,
forceElevated: innerBoxIsScrolled,
bottom: TabBar(
tabs: tabs
.map((String name) => Tab(text: name))
.toList(),
),
),
const SliverPinnedHeader(
child: SafeArea(
child: Padding(
padding: EdgeInsets.all(16),
child: Text('Test')))),
],
),
),
),
];
},
body: TabBarView(
// These are the contents of the tab views, below the tabs.
children: tabs.map((String name) {
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) {
return CustomScrollView(
key: PageStorageKey<String>(name),
slivers: <Widget>[
SliverOverlapInjector(
// This is the flip side of the SliverOverlapAbsorber
// above.
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
),
SliverPadding(
padding: const EdgeInsets.all(8.0),
sliver: SliverFixedExtentList(
itemExtent: 48.0,
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return ListTile(
title: Text('Item $index'),
);
},
childCount: 30,
),
),
),
],
);
},
),
);
}).toList(),
),
),
),
);
}
}
The bug flutter/flutter#91256 as you mentioned is confirmed if SliverAppBar is not first in the list.
from sliver_tools.
Related Issues (20)
- SliverPinnedHeader and detecting overlapping (i.e. overlapsContent) HOT 1
- Is there any way I can listen when the header sticks to the top?
- Add SliverClip.clipBehavior HOT 1
- SliverPinnedHeader add offsetTop can not work correctly HOT 3
- issues with dynamic list data HOT 2
- AbstractNode is deprecated
- Error: A constant constructor can't call a non-constant super constructor. HOT 2
- Workaround for adding Sliver into an IndexedStack HOT 1
- Flutter 3.13 Compatibility HOT 2
- `SliverList` breaks alignment in `SliverStack` HOT 2
- Flutter build fails with error after new update! HOT 4
- Question: Trying to combine a SliverPinnedHeader with an SliverAppBar that has a bottom widget HOT 4
- Missing tag on GitHub HOT 2
- [Enhancement Request] SliverAnimationSwitcher with transitionBuilder HOT 1
- sliver_tools vs normal slivers HOT 1
- Please provide the full example code from the gif HOT 3
- Multiple SliverPinnedHeader overlapping HOT 2
- How to make it fit with custom ExpansionTile Widget ? HOT 1
- Add SliverSizeTransition HOT 6
- MultiSliver fails in a shrinkwrapped, unconstrained CustomScrollView HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sliver_tools.