当前位置:网站首页>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,
],
),
),
);
}
);
}
边栏推荐
- 仿ps样式js网页涂鸦板插件
- 宝塔 7.9.2 宝塔控制面板绕过 手机绑定认证 绕过官方认证
- Jerry's ad series MIDI function description [chapter]
- Flutter WebView示例
- [buuctf.reverse] 151_ [FlareOn6]DnsChess
- 华为模拟器ensp的路由配置以及连通测试
- Maidong Internet won the bid of Beijing life insurance
- 刘锦程荣获2022年度中国电商行业创新人物奖
- 改善机器视觉系统的方法
- Three or two things about the actual combat of OMS system
猜你喜欢
Gobang go to work fishing tools can be LAN / man-machine
杰理之AD 系列 MIDI 功能说明【篇】
Solution of 5g unstable 5g signal often dropped in NetWare r7000 Merlin system
TweenMax表情按钮js特效
Introduction to pressure measurement of JMeter
创客思维在高等教育中的启迪作用
华为ensp模拟器实现通信安全(交换机)
华为ensp模拟器 DNS服务器的配置
Three or two things about the actual combat of OMS system
c语言函数形参自增自减情况分析
随机推荐
redis RDB AOF
colResizable.js自动调整表格宽度插件
解读创客教育中的各类智能化组织发展
2021 CCPC 哈尔滨 I. Power and Zero(二进制 + 思维)
[wechat applet] collaborative work and release
面试官:说说XSS攻击是什么?
【C语言】符号的深度理解
MP3是如何诞生的?
TweenMax表情按钮js特效
【公开课预告】:视频质量评价基础与实践
WGCNA分析基本教程总结
torch. Tensor and torch The difference between tensor
heatmap.js图片热点热力图插件
【optimtool.unconstrain】无约束优化工具箱
In the release version, the random white screen does not display the content after opening the shutter
Poster cover of glacier
redis事务
Nmap scan
Day24:文件系统
Procurement in software development