You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中CupertinoRefreshControl加载图标无法自动消失问题求助

关于CupertinoRefreshControl加载图标不消失的问题排查

你遇到的这个问题确实挺让人头疼:下拉刷新完成后,页面内容已经正常更新(文本从"Hello Refresh"切换为"Bye Refresh"),但CupertinoRefreshControl的加载图标却一直停留在屏幕上,没有自动收起。先看看你提供的复现效果:

下拉刷新后加载图标未消失

复现代码

你用来复现问题的测试代码如下:

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'dart:async';
import 'dart:ui';

class _RefreshTestState extends State<RefreshTest> {
  bool flag = false;

  @override
  Widget build(BuildContext context) {
    return new CupertinoPageScaffold(
      backgroundColor: const Color(0xFFEFEFF4),
      child: new CustomScrollView(slivers: <Widget>[
        new CupertinoSliverNavigationBar(largeTitle: new Text('TESTING'),),
        new CupertinoRefreshControl(onRefresh: () {
          return new Future<void>.delayed(const Duration(seconds: 1))
            ..then((_) => setState(() {
              flag = !flag;
            }));
        }),
        new SliverSafeArea(
          top: false,
          sliver: new SliverList(
            delegate: new SliverChildBuilderDelegate(
              (BuildContext context, int index) {
                return flag? new Text("Hello Refresh.") : new Text("Bye refresh");
              },
              childCount: 2,
            ),
          ),
        )
      ]),
    );
  }
}

class RefreshTest extends StatefulWidget {
  @override
  Widget build(BuildContext context) {
    // 注:StatefulWidget无需重写build方法,此处属于代码不规范,建议删除该方法
    throw UnimplementedError();
  }

  @override
  _RefreshTestState createState() => new _RefreshTestState();
}

问题现状

目前这个问题已经在Flutter官方仓库被提交为Issue,不过暂时还没有官方给出的解决方案。

内容的提问来源于stack exchange,提问作者Simon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:30:47