Flutter 下拉刷新之RefreshIndicator

效果

在这里插入图片描述

属性

RefreshIndicatorMaterial 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回调即可。


使用

  @override
  Widget build(BuildContext context) {
    return Scaffold(
    
      body: RefreshIndicator(
        //指示器颜色
        color: Theme.of(context).primaryColor,
        //指示器显示时距顶部位置
        displacemen

猜你喜欢

转载自blog.csdn.net/yechaoa/article/details/98193911