根据flutter_boost 官网介绍,回传后then 方法回调 支持的是 native 页面退出时,传递参数给上一个flutter页面
// 1. 从Flutter页面打开一个Native页面,并处理返回结果
InkWell(
child: Container(
padding: const EdgeInsets.all(8.0),
margin: const EdgeInsets.all(8.0),
color: Colors.yellow,
child: Text(
'open native page',
style: TextStyle(fontSize: 22.0, color: Colors.black),
)),
onTap: () => BoostNavigator.instance
.push("ANativePage") // Native页面路由
.then((value) => print('retval:$value')),
),
同样的方法 push flutter页面后,发现 then 回调没有执行
//这样 then 不会执行
BoostNavigator.instance.push(
"catPluginSettingClockPage",
withContainer: false,
).then((value){
//进行页面刷新
_catDeviceSettingController.getDeviceClock();
print("从定时列表返回到设置页");
});
于是,直接使用flutter 提供的路由跳转方法,结果then回调可以执行
//这样 then 才会执行
Route route = MaterialPageRoute(builder: (context) => ClockCleanPage());
Navigator.push(context, route).then((value){
//进行页面刷新
_catDeviceSettingController.getDeviceClock();
print("从定时列表返回到设置页");
});
有懂的老铁,帮忙分析一下
flutter 版本
[✓] Flutter (Channel stable, 3.13.0, on macOS 13.3.1 22E772610a darwin-x64,
locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
[✓] VS Code (version 1.81.1)
[✓] Connected device (4 available)
[✓] Network resources
flutter_boost版本
flutter_boost:
dependency: "direct main"
description:
path: "."
ref: "4.4.0"
resolved-ref: d8fd7454b775d91710e30166a62e4810b1695fcf
url: "https://github.com/alibaba/flutter_boost.git"
source: git
version: "4.4.0"