WillPopScope组件
用WillPopScope包裹根页面组件
WillPopScope( onWillPop: _requestPop, child: pageContainer() )
其中onWillPop绑定的函数就是系统返回事件触发后的处理函数
Future<bool> _requestPop() async { // 调用原生返回,返回原生页面,根据自身场景自己定义处理函数 const platform = MethodChannel("flutterBackNative"); try { final int res = await platform.invokeMethod("flutterBackNative"); } on PlatformException catch (e) { print(e); } return Future.value(false); }
标签:返回,触发,flutterBackNative,flutter,platform,自带,WillPopScope,处理函数 From: https://www.cnblogs.com/liangqilin/p/17756756.html