如何在返回特定屏幕之前调用方法



我有一个ui屏幕显示数据查询从本地数据库,让这个ui数据同步与本地数据源,我需要调用一个数据库。Get.back()、Get.off()等导航前的查询方法

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

把你的方法放在…

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

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

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

最新更新