效果

属性
RefreshIndicator 是 Material Design 风格的下拉刷新控件,所以同android中的SwipeRefreshLayout用法一样,嵌套在外层即可。
先了解一下属性:
const RefreshIndicator({
Key key,
@required this.child,
this.displacement = 40.0,//指示器显示时距顶部位置
@required this.onRefresh,//下拉刷新回调
this.color,//指示器颜色,默认ThemeData.accentColor
this.backgroundColor,//指示器背景颜色,默认ThemeData.canvasColor
this.notificationPredicate = defaultScrollNotificationPredicate,
this.semanticsLabel,
this.semanticsValue,
})
基本上只需要关心onRefresh回调即可。

本文介绍了在Flutter中使用RefreshIndicator实现下拉刷新的功能,并提供了简单的代码示例。同时,文章提到了如何结合ScrollController实现上拉加载更多,并强调了在处理加载状态时应定义并管理好各种状态,以保持逻辑清晰。最后,提供了开源项目的GitHub链接供读者参考。
订阅专栏 解锁全文
738

被折叠的 条评论
为什么被折叠?



