当前位置:网站首页>Monitor the shuttle return button
Monitor the shuttle return button
2022-07-04 21:32:00 【Boundless 6688】
Monitoring of physical buttons and return buttons
Flutter The return button is monitored through WillPopScope To achieve
class BackDemoState extends State<BackDemoWidget> {
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _onWillPop,
child: Scaffold(
appBar: AppBar(
title: const Text(" Back key monitor "),
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: (){
SmartDialog.showToast(" return ");
if (Navigator.canPop(context)) {
Navigator.pop(context);
} else {
SystemNavigator.pop();
}
},
),
),
));
}
Future<bool> _onWillPop() {
SmartDialog.showToast(" return ");
if (Navigator.canPop(context)) {
Navigator.pop(context);
} else {
SystemNavigator.pop();
}
return Future.value(false);
}
}
WebView Return listening of
@override
Widget build(BuildContext context) {
return FutureBuilder<WebViewController>(
future: _controller.future,
builder: (context, snapshot) {
return WillPopScope(
onWillPop: () async {
if (snapshot.hasData) {
final bool canGoBack = await snapshot.data!.canGoBack();
if (canGoBack) {
// When a web page can be returned , Return to the previous page first
await snapshot.data!.goBack();
return Future.value(false);
}
}
return Future.value(true);
},
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Stack(
children: [
WebView(
initialUrl: "https://www.baidu.com",
javascriptMode: JavascriptMode.unrestricted,
allowsInlineMediaPlayback: true,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
onProgress: (int progress) {
debugPrint('WebView is loading (progress : $progress%)');
setState(() {
_progressValue = progress;
});
},
),
if (_progressValue != 100) LinearProgressIndicator(
value: _progressValue / 100,
backgroundColor: Colors.transparent,
minHeight: 2,
) else Gaps.empty,
],
),
),
);
}
);
}
边栏推荐
猜你喜欢
多模輸入事件分發機制詳解
Compréhension approfondie du symbole [langue C]
华为ensp模拟器 给路由器配置DHCP
FastDfs的快速入门,三分钟带你上传下载文件到云服务器
Jerry added the process of turning off the touch module before turning it off [chapter]
【微信小程序】协同工作与发布
华为ensp模拟器 配置ACL访问控制列表
Maidong Internet won the bid of Beijing life insurance
JS卡牌样式倒计时天数
[public class preview]: basis and practice of video quality evaluation
随机推荐
PS vertical English and digital text how to change direction (vertical display)
华为ensp模拟器 DNS服务器的配置
华为ensp模拟器实现通信安全(交换机)
Render function and virtual DOM
Delphi SOAP WebService 服务器端多个 SoapDataModule 实现相同的接口方法,接口继承
[C language] deep understanding of symbols
TCP三次握手,四次挥手,你真的了解吗?
Jerry added the process of turning off the touch module before turning it off [chapter]
2021 CCPC 哈尔滨 B. Magical Subsequence(思维题)
__init__() missing 2 required positional arguments 不易查明的继承错误
Methods of improving machine vision system
minidom 模塊寫入和解析 XML
redis RDB AOF
[wechat applet] collaborative work and release
Kubeadm初始化报错:[ERROR CRI]: container runtime is not running
Test case (TC)
Jerry's ad series MIDI function description [chapter]
__ init__ () missing 2 required positive arguments
华为ensp模拟器 配置ACL访问控制列表
Y56. Chapter III kubernetes from entry to proficiency -- business image version upgrade and rollback (29)