当前位置:网站首页>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,
],
),
),
);
}
);
}
边栏推荐
猜你喜欢

巅峰不止,继续奋斗!城链科技数字峰会于重庆隆重举行

torch.tensor和torch.Tensor的区别

Detailed explanation of multi-mode input event distribution mechanism

Foxit pdf editor v10.1.8 green version
![Compréhension approfondie du symbole [langue C]](/img/4b/26cf10baa29eeff08101dcbbb673a2.png)
Compréhension approfondie du symbole [langue C]

Huawei ENSP simulator configures ACL access control list

Render function and virtual DOM

【C语言】符号的深度理解

如何使用ConcurrentLinkedQueue做一个缓存队列

PS vertical English and digital text how to change direction (vertical display)
随机推荐
y56.第三章 Kubernetes从入门到精通 -- 业务镜像版本升级及回滚(二九)
c语言函数形参自增自减情况分析
Google colab踩坑
【C語言】符號的深度理解
redis管道
[micro service SCG] use of predict
For MySQL= No data equal to null can be found. Solution
Difference between ApplicationContext and beanfactory (MS)
redis缓存
[C language] deep understanding of symbols
[Shenbo introduction] VI How to contact your favorite doctoral tutor
A quick start to fastdfs takes you three minutes to upload and download files to the ECS
TweenMax表情按钮js特效
Advantages of RFID warehouse management system solution
OMS系统实战的三两事
async await 在map中使用
迈动互联中标北京人寿保险
如何使用ConcurrentLinkedQueue做一个缓存队列
Redis bloom filter
每日一题-LeetCode556-下一个更大元素III-字符串-双指针-next_permutation