Flutter 是否可以让SmartRefresh在到达按钮前预加载更多内容
现在,我正在使用flifter中的Flutter 是否可以让SmartRefresh在到达按钮前预加载更多内容,flutter,Flutter,现在,我正在使用flifter中的smartrefresh在我的应用程序中加载更多内容,但当内容到达查看按钮时,它必须触发拉拽,我阅读了文档并找到了有关头重新加载的配置: headerTriggerDistance: 80.0, // header trigger refresh trigger distance 在到达按钮之前,是否可能使按钮触发负载更大?这是我的代码: child: CupertinoScrollbar( child:
smartrefresh
在我的应用程序中加载更多内容,但当内容到达查看按钮时,它必须触发拉拽,我阅读了文档并找到了有关头重新加载的配置:
headerTriggerDistance: 80.0, // header trigger refresh trigger distance
在到达按钮之前,是否可能使按钮触发负载更大?这是我的代码:
child: CupertinoScrollbar(
child:SmartRefresher(
onRefresh: () {
_refreshController.refreshCompleted();
},
enablePullUp: true,
enablePullDown: true,
controller: _refreshController,
onLoading: () {
dispatch(
HomeListDefaultActionCreator.onLoadingMoreArticles(
articleRequest));
_refreshController.loadComplete();
},
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text("上拉加载更多");
} else if (mode == LoadStatus.loading) {
//body = CupertinoActivityIndicator();
} else if (mode == LoadStatus.failed) {
body = Text("加载失败!点击重试!");
} else if (mode == LoadStatus.canLoading) {
body = Text("release to load more");
} else {
body = Text("No more Data");
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
),
child: CustomScrollView()
)))
您可以使用NotificationListener包装CustomScrollView,然后在滚动位置接近滚动内容底部时使用onNotification属性执行操作 下面是如何使用NotificationListener的一个示例。现在我这样做:
return NotificationListener(
onNotification: (scrollNotification) {
if (scrollNotification is! ScrollNotification) {
return false;
}
autoPreloadMoreArticles(scrollNotification);
return true;
}
}
并加载更多文章:
void autoPreloadMoreArticles(ScrollNotification notification) {
if (notification is ScrollUpdateNotification) {
ScrollMetrics metrics = notification.metrics;
double buttonDistance = metrics.extentAfter;
if (buttonDistance < 800 && !isDispatched) {
isDispatched = true;
_loadingMoreArticle();
}
if (buttonDistance > 800) {
isDispatched = false;
}
}
}
void autoPreloadMoreArticles(滚动通知){
如果(通知为ScrollUpdateNotification){
ScrollMetrics=notification.metrics;
double ButtonInstance=metrics.extentAfter;
如果(按钮位置<800&&!已发布){
isDispatched=真;
_加载morearticle();
}
如果(按钮位置>800){
isDispatched=假;
}
}
}