Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在flutter中创建刷新页面按钮?_Flutter - Fatal编程技术网

如何在flutter中创建刷新页面按钮?

如何在flutter中创建刷新页面按钮?,flutter,Flutter,如何在flutter中创建刷新页面按钮 new IconButton( icon: new Image.asset( '../assets/images/iconRefresh.png', width: 31, height: 31, ), tooltip: 'Refresh', onPressed: iconButton

如何在flutter中创建刷新页面按钮

            new IconButton(
          icon: new Image.asset(
            '../assets/images/iconRefresh.png',
            width: 31,
            height: 31,
          ),
          tooltip: 'Refresh',
          onPressed: iconButtonPressed,
        ),

我不知道它的功能。老实说,我是编程新手,所以请帮助我:)

在Flutter中,您可以非常轻松地重建小部件。您只需调用
setState
函数,颤振将再次运行构建。如果在您的状态中有任何更改,它将被更新。请注意,这仅适用于有状态小部件

void updateUI(){
   setState(() {
      //You can also make changes to your state here.
    });
}

您可以使用Refreshindicator小部件 下面是示例

RefreshIndicator(
    key: _refreshIndicatorKey,
    onRefresh: _refresh,
    child: ListView(children: [
      // body of above
    ])),
下面是刷新的方法

Future<Null> _refresh() {
  // You can do part here what you want to refresh
}
Future\u refresh(){
//你可以在这里做你想刷新的部分
}
您可以在下面提到的链接中查看完整的示例:


由于您不清楚您提到的“按钮”,您可以使用设置状态进行更改。

您希望使用按钮刷新什么?请提供更多信息和代码。您可以使用setState刷新页面