kidd3166 cde79e9670 flutter 2.0 update | 3 gadi atpakaļ | |
---|---|---|
.. | ||
.github | 3 gadi atpakaļ | |
.vscode | 3 gadi atpakaļ | |
lib | 3 gadi atpakaļ | |
.gitignore | 3 gadi atpakaļ | |
.metadata | 3 gadi atpakaļ | |
CHANGELOG.md | 3 gadi atpakaļ | |
LICENSE | 3 gadi atpakaļ | |
README-ZH.md | 3 gadi atpakaļ | |
README.md | 3 gadi atpakaļ | |
analysis_options.yaml | 3 gadi atpakaļ | |
pubspec.yaml | 3 gadi atpakaļ |
扩展NestedScrollView来修复了下面的问题
3.下拉刷新不能工作
4.在NestedScrollView的body中不通过设置ScrollController(设置了会跟内部Controller冲突)来完成下拉刷新,增量加载,滚动到顶部
Web demo for ExtendedNestedScrollView
Do without ScrollController in NestedScrollView's body
在pinnedHeaderSliverHeightBuilder回调中设置全部pinned的header的高度, demo里面高度为 状态栏高度+SliverAppbar的高度
var tabBarHeight = primaryTabBar.preferredSize.height;
var pinnedHeaderHeight =
//statusBar height
statusBarHeight +
//pinned SliverAppBar height in header
kToolbarHeight;
return NestedScrollView(
pinnedHeaderSliverHeightBuilder: () {
return pinnedHeaderHeight;
},
TabbarView里面的列表,使用NestedScrollViewInnerScrollPositionKeyWidget包住,并且设置唯一key, 这个key跟列表是第几个tab有关系。
return extended.NestedScrollViewInnerScrollPositionKeyWidget(
widget.tabKey,
ListView.builder(
itemBuilder: (c, i) {
return Container(
alignment: Alignment.center,
height: 60.0,
child: Text(widget.tabKey.toString() + ": List$i"),
);
},
itemCount: 100)
);
innerScrollPositionKeyBuilder回调中给出当前tab的key. 这个key应该跟第一步中相同
extended.NestedScrollView(
innerScrollPositionKeyBuilder: () {
var index = "Tab";
if (primaryTC.index == 0) {
index +=
(primaryTC.index.toString() + secondaryTC.index.toString());
} else {
index += primaryTC.index.toString();
}
return Key(index);
},
NestedScrollViewRefreshIndicator is as the same as Flutter RefreshIndicator.
NestedScrollViewRefreshIndicator(
onRefresh: onRefresh,
child: extended.NestedScrollView(
headerSliverBuilder: (c, f) {
return _buildSliverHeader(primaryTabBar);
},
建议使用这个来做NestedScrollView的整体下拉刷新
Please see the example app of this for a full example.
因为无法给NestedScrollView的body中的列表设置ScrollController(这样会破坏NestedScrollView内部的InnerScrollController的行为),所以我这里给大家提供了Demos来展示怎么不通过ScrollController来完成