flutter 中的 RefreshIndicator 问题

问题描述 投票:0回答:1
if (subStatuses.isEmpty) {
  // No second tab bar needed if subStatuses is empty
  return RefreshIndicator(
    child: ListView.builder(
      physics: const BouncingScrollPhysics(),
      shrinkWrap: true,
      itemCount: applicants.length,
      itemBuilder: (context, index) {
        final applicant = applicants[index];
        return listViewItem_new(
          context,
          applicant,
          true,
          statuses,
          profilemodel.id != null
              ? profilemodel.id!.toInt()
              : 467,
          index,
        );
      },
    ),
  );
}

在这里,我尝试使用 RefreshIndicator,但收到错误“”'RefreshIndicator' 不是函数。 尝试更正名称以匹配现有函数,或定义名为“RefreshIndicator”的方法或函数。""

据我说没有其他问题,但我不知道为什么会发生这种情况......

flutter refresh pull-to-refresh
1个回答
0
投票

尝试添加刷新方法

return RefreshIndicator(
  onRefresh: () {
    //write the call to method you want to run on refreshing
  },
  child: ListView.builder(
    physics: const BouncingScrollPhysics(),
    shrinkWrap: true,
    itemCount: applicants.length,
    itemBuilder: (context, index) {
      final applicant = applicants[index];
      return listViewItem_new(
        context,
        applicant,
        true,
        statuses,
        profilemodel.id != null ? profilemodel.id!.toInt() : 467,
        index,
      );
    },
  ),
);
© www.soinside.com 2019 - 2024. All rights reserved.