如何访问RefreshIndicator的RefreshIndicatorState?

Dun*_*nes 3 widget material-design flutter

文档RefreshIndicator建议您可以通过类以编程方式触发刷新行为RefreshIndicatorState

假设我已经将一个小部件添加到我的应用程序中,如何访问此类的实例RefreshIndicator?我看不到访问它的属性,我假设createState()仅由 Flutter 框架使用。

为了避免XY 问题,我应该解释一下我这样做的原因是当我的用户第一次打开应用程序时对我的列表执行视觉上令人愉悦的刷新。该列表最初为空,刷新将轮询我的服务器以获取数据。

xst*_*ter 8

请参阅https://docs.flutter.io/flutter/material/RefreshIndicatorState/show.html以及Flutter Gallery 中的使用示例

本质上

var indicator = new GlobalKey<RefreshIndicatorState>();
Run Code Online (Sandbox Code Playgroud)

进而

indicator.currentState.show();
Run Code Online (Sandbox Code Playgroud)

建成后。