如何访问RefreshIndicator的RefreshIndicatorState?

时间:2018-04-10 17:43:38

标签: widget material-design flutter

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

如果我在应用程序中添加了RefreshIndicator窗口小部件,我该如何访问此类的实例?我看不到要访问它的属性,我假设createState()仅由Flutter框架使用。

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

1 个答案:

答案 0 :(得分:1)

在Flutter Gallery中查看https://docs.flutter.io/flutter/material/RefreshIndicatorState/show.htmlusage example

基本上

var indicator = new GlobalKey<RefreshIndicatorState>();

然后

indicator.currentState.show();

在它建成后。