当前位置:网站首页>(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)
边栏推荐
- three.js绚烂的气泡效果
- Jafka source analysis processor
- Adavit -- dynamic network with adaptive selection of computing structure
- DockerMySQL无法被宿主机访问的问题解决
- 项目复盘模板
- 华为云GaussDB(for Redis)揭秘第21期:使用高斯Redis实现二级索引
- 允许全表扫描 那个语句好像不生效set odps.sql.allow.fullscan=true;我
- ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
- 专为决策树打造,新加坡国立大学&清华大学联合提出快速安全的联邦学习新系统
- AdaViT——自适应选择计算结构的动态网络
猜你喜欢

How to confirm the storage mode of the current system by program?

uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)

Export MySQL table data in pure mode

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

View

【编译原理】做了一半的LR(0)分析器

Custom swap function

European Bioinformatics Institute 2021 highlights report released: nearly 1million proteins have been predicted by alphafold

How to choose indoor LED display? These five considerations must be taken into account

自定义 swap 函数
随机推荐
Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
ICLR 2022 | pre training language model based on anti self attention mechanism
ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型
Machine test question 1
BasicVSR_PlusPlus-master测试视频、图片
Const keyword
Dayu200 experience officer runs the intelligent drying system page based on arkui ETS on dayu200
Traversal of a tree in first order, middle order, and then order
Introduction to network basics
POJ 1258 Agri-Net
C# 三种方式实现Socket数据接收
MySQL实现字段分割一行转多行的示例代码
Cocoscreator+typescripts write an object pool by themselves
Project duplicate template
浅谈网络安全之文件上传
DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
The ceiling of MySQL tutorial. Collect it and take your time
Return keyword
Jafka source analysis processor
服务器的系统怎么选者