当前位置:网站首页>(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)
边栏推荐
- On file uploading of network security
- ThreadLocal详解
- How to use flexible arrays?
- The ceiling of MySQL tutorial. Collect it and take your time
- Introduction to network basics
- 华为云GaussDB(for Redis)揭秘第21期:使用高斯Redis实现二级索引
- 【全网首发】Redis系列3:高可用之主从架构的
- Is there any requirement for the value after the case keyword?
- CRMEB商城系统如何助力营销?
- DockerMySQL无法被宿主机访问的问题解决
猜你喜欢
Sword finger offer question brushing record 1
【LeetCode】19、 删除链表的倒数第 N 个结点
Custom swap function
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
mysql拆分字符串作为查询条件的示例代码
Cocoscreator+typescripts write an object pool by themselves
[leetcode] 19. Delete the penultimate node of the linked list
2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9
#DAYU200体验官# 首页aito视频&Canvas绘制仪表盘(ets)
监控界的最强王者,没有之一!
随机推荐
自定义 swap 函数
Les entreprises ne veulent pas remplacer un système vieux de dix ans
European Bioinformatics Institute 2021 highlights report released: nearly 1million proteins have been predicted by alphafold
config:invalid signature 解决办法和问题排查详解
案例推荐丨安擎携手伙伴,保障“智慧法院”更加高效
如何实现文字动画效果
DockerMySQL无法被宿主机访问的问题解决
QT signal and slot
Hard core observation 545 50 years ago, Apollo 15 made a feather landing experiment on the moon
DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
[step on pit collection] attempting to deserialize object on CUDA device+buff/cache occupy too much +pad_ sequence
Redis 持久化机制
The difference between enumeration and define macro
Improving Multimodal Accuracy Through Modality Pre-training and Attention
Cloud native technology container knowledge points
Aardio - Method of batch processing attributes and callback functions when encapsulating Libraries
【无标题】
Method of canceling automatic watermarking of uploaded pictures by CSDN
Aardio - does not declare the method of directly passing float values
Case recommendation: An Qing works with partners to ensure that the "smart court" is more efficient