【问题标题】:How to refresh a page other than the current one in flutter如何刷新当前页面以外的页面
【发布时间】:2022-11-02 23:14:27
【问题描述】:

我想更新用户按下按钮的页面以外的页面,我知道要更新页面本身只需使用

setState (() {})

但我想做的是在用户按下 main.dart 页面上的按钮时更新主页。我该如何解决?

我的想法并且它有效但糟糕的是使用

Navigator.push (context, MaterialPageRoute (builder: (context) => const MyApp ()));

当用户按下按钮时,它会起作用,因为它会更新我的 MyApp (main.dart),问题是当他们以这种方式按下按钮时,您会看到与打开应用程序时相同的动画,而且非常丑陋的。

【问题讨论】:

    标签: flutter button page-refresh


    【解决方案1】:

    您可以将其中包含 setState 的函数传递到其他页面并在单击按钮后运行该函数

    【讨论】:

      猜你喜欢
      • 2015-12-01
      • 1970-01-01
      • 2018-09-15
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-03
      • 2013-07-21
      相关资源
      最近更新 更多