颤动:CupertinoRefreshControl不解雇

时间:2018-05-12 10:46:50

标签: flutter

我构建了以下小测试代码来演示我在Flutter上遇到的问题:

enter image description here

从gif中,您可以看到应用程序拉动刷新并且条子文本从“Hello Refresh”更新为“Bye Refresh”,但是,CupertinoRefreshControl加载图标在文本更改后不会消失。 当新数据加载到Sliver时,我原本预计加载图标会消失:

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) {
    // TODO: implement build
    // TODO: implement build
    return new CupertinoPageScaffold(
      //i will need to convert this to a sliver list to make this work properly.
      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(() {
              if (flag) {
                flag = false;
              } else {
                flag = true;
              }
            }));
        }),
        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) {

  }

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

}

我发现此问题的github线程也已启动,但尚未发布任何解决方案:https://github.com/flutter/flutter/issues/17474

1 个答案:

答案 0 :(得分:0)

随后发现,当列表不够长时,拉动刷新时刷新旋转图标不会消失。 几个月后通过flutter更新解决了该问题,因此对于新的flutter,此问题将不再出现。