【问题标题】:How to call a method before back to the specific screen如何在返回特定屏幕之前调用方法
【发布时间】:2021-11-16 16:51:04
【问题描述】:

我有一个 ui 屏幕来显示来自本地数据库的数据查询,为了让这个 ui 数据与本地数据源同步,我需要在导航之前调用 db.query 方法,如 Get.back() 和 Get.off ()。

我也想过在GetxController中使用.obs变量,但是当数据来自后台推送等服务时,无法访问getx状态。

【问题讨论】:

    标签: flutter flutter-getx


    【解决方案1】:

    要么把你的方法放进去..

       WillPopScope(
          onWillPop: () async { //method },
          child: Scaffold(
            appBar: AppBar(
              title: new Text("Home Page"),
            ),
    

      @override
      void dispose() {
        //method
        super.dispose();
      }
    

    WillPopScope 处理后退按钮,而 dispose() 在小部件被销毁时被调用

    【讨论】:

      猜你喜欢
      • 2010-10-11
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 2017-07-02
      • 1970-01-01
      • 2015-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多