当前位置:网站首页>(shuttle) navigation return interception: willpopscope
(shuttle) navigation return interception: willpopscope
2022-07-06 22:56:00 【Xiaobai is more than that】
1. Calculate the time difference between two dates
DateTime.now().difference(_lastPressedAt!)
// Use difference Method , You can get the difference of all time units
among ,DateTime Of difference Method Back to a Duration object .Duration It's used to show time span ( Difference value ) Class .
Reference article :
Flutter Calculate the time difference between two dates
Xiaobai is more than that :(Dart) Usage supplement
2. Navigation returns to intercept : WillPopScope
DateTime? _lastPressedAt; // Last click time
@override
Widget build(BuildContext context) {
return WillPopScope(
child: Scaffold(
body: Container(
alignment: Alignment.center,
child: Text("2 Press the return key twice in a row within seconds to exit "),
),
),
onWillPop: () async {
if (_lastPressedAt == null || DateTime.now().difference(_lastPressedAt!) > Duration(seconds: 2)) {
// The interval between two clicks is more than 2 Second is the second
_lastPressedAt = DateTime.now();
Fluttertoast.showToast(
msg: ' Press again to exit !',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 2,
backgroundColor: Colors.black87,
textColor: Colors.white,
);
return false;// Current route does not stack ( Will not return )
}
return true;// The current route exits the stack
},
);
}

Reference article :
Navigation returns to intercept (WillPopScope)
边栏推荐
- CRMEB商城系统如何助力营销?
- Uniapp setting background image effect demo (sorting)
- leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
- POJ 1258 Agri-Net
- MATLAB小技巧(27)灰色预测
- [step on pit collection] attempting to deserialize object on CUDA device+buff/cache occupy too much +pad_ sequence
- Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
- three. JS gorgeous bubble effect
- QT signal and slot
- Case recommendation: An Qing works with partners to ensure that the "smart court" is more efficient
猜你喜欢

浅谈网络安全之文件上传

Aardio - Method of batch processing attributes and callback functions when encapsulating Libraries

Word2vec (skip gram and cbow) - pytorch

leetcode:面试题 17.24. 子矩阵最大累加和(待研究)

Signed and unsigned keywords

动作捕捉用于蛇运动分析及蛇形机器人开发

Slide the uniapp to a certain height and fix an element to the top effect demo (organize)

#DAYU200体验官# 首页aito视频&Canvas绘制仪表盘(ets)

config:invalid signature 解决办法和问题排查详解

云原生技术--- 容器知识点
随机推荐
Export MySQL table data in pure mode
使用云服务器搭建代理
Aardio - integrate variable values into a string of text through variable names
Case recommendation: An Qing works with partners to ensure that the "smart court" is more efficient
OpenSSL: a full-featured toolkit for TLS and SSL protocols, and a general encryption library
docker中mysql开启日志的实现步骤
【踩坑合辑】Attempting to deserialize object on CUDA device+buff/cache占用过高+pad_sequence
uniapp设置背景图效果demo(整理)
[IELTS speaking] Anna's oral learning record part1
2014 Alibaba web pre intern project analysis (1)
Custom swap function
npm无法安装sharp
室内LED显示屏应该怎么选择?这5点注意事项必须考虑在内
On file uploading of network security
DockerMySQL无法被宿主机访问的问题解决
Method of canceling automatic watermarking of uploaded pictures by CSDN
Is there any requirement for the value after the case keyword?
How to choose the server system
Improving Multimodal Accuracy Through Modality Pre-training and Attention
Rust knowledge mind map XMIND