zoukankan      html  css  js  c++  java
  • flutter上拉加载更多下拉刷新

    在pubspec.yaml中
      pull_to_refresh: 1.6.3 
     
    页面中
     RefreshController _refreshController;
     int pageNo = 1;
      @override
      void initState() {
        super.initState();
        _refreshController = RefreshController(initialRefresh: false);
      }

      // 下拉刷新
      void _onRefresh() async {
        pageNo = 1;
      _refreshController.loadComplete();
      }

      // 上拉加载更多
      void _onLoading() async {
        pageNo++;
      _refreshController.loadComplete();
      }
    RefreshConfiguration.copyAncestor(
            context: context,
            // Viewport不满一屏时,禁用上拉加载更多功能,应该配置更灵活一些,比如说一页条数大于等于总条数的时候设置或者总条数等于0
            hideFooterWhenNotFull: true,
            child: SmartRefresher(
              enablePullDown: true,
              enablePullUp: true,
              header: WaterDropHeader(),
              controller: _refreshController,
              onRefresh: _onRefresh,
              onLoading: _onLoading,
              child: CustomScrollView(
                slivers: [
                  SliverList(
                    delegate: SliverChildBuilderDelegate((BuildContext context, int i) {
                      return BListItem(
                        height: 50,
                        enableChecked: true,
                        title: data[i].name,
                        onTap: () => onTap(data[i]),
                        titleStyle: TextStyle(fontSize: 15, color: Colors.black),
                        isChecked: _activeCode == data[i].code,
                      );
                    }, childCount: data?.length ?? 0),
                  ),
                ],
              ),
            ),
          ),
     
    需要注意的就是SmartRefresher的child需要直接加这种CustomScrollView或者listview等可滚动的组件
    本人小白,各位想踏入前端的,我们可以一起学习,欢迎程序员大佬的指点
  • 相关阅读:
    font-weight 导致iconfont显示有问题和糊
    compositionstart与compositionend解决组合文字输入问题
    工具函数 createOnceHandler 只执行一次的事件绑定
    redis的基本数据类型
    dubbo服务的发布和调用
    Dubbo介绍和服务架构分析
    spring的事务配置方法
    [已解决] java.net.ConnectException: Connection refused: no further information
    [已解决] 点击 【Show in system explorer】Eclipse卡死,未响应
    [已解决] java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.com.yourproject.test_jsp
  • 原文地址:https://www.cnblogs.com/xiao-lei-ge/p/14745398.html
Copyright © 2011-2022 走看看