当前位置:网站首页>(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)
边栏推荐
- Word2vec (skip gram and cbow) - pytorch
- Hard core observation 545 50 years ago, Apollo 15 made a feather landing experiment on the moon
- 案例推荐丨安擎携手伙伴,保障“智慧法院”更加高效
- The statement that allows full table scanning does not seem to take effect set odps sql. allow. fullscan=true; I
- Thinkphp5 multi table associative query method join queries two database tables, and the query results are spliced and returned
- [step on pit collection] attempting to deserialize object on CUDA device+buff/cache occupy too much +pad_ sequence
- Cloud native technology container knowledge points
- How to use flexible arrays?
- BasicVSR_ Plusplus master test videos and pictures
- 动作捕捉用于蛇运动分析及蛇形机器人开发
猜你喜欢
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
让我们,从头到尾,通透网络I/O模型
How to confirm the storage mode of the current system by program?
#DAYU200体验官# 首页aito视频&Canvas绘制仪表盘(ets)
Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
金融人士必读书籍系列之六:权益投资(基于cfa考试内容大纲和框架)
On the problems of born charge and non analytical correction in phonon and heat transport calculations
Export MySQL table data in pure mode
随机推荐
hdu 5077 NAND(暴力打表)
华为云GaussDB(for Redis)揭秘第21期:使用高斯Redis实现二级索引
Pytest unit test series [v1.0.0] [pytest execute unittest test case]
Traversal of a tree in first order, middle order, and then order
MySQL中正则表达式(REGEXP)使用详解
企業不想換掉用了十年的老系統
Machine test question 1
DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
three. JS gorgeous bubble effect
Uniapp setting background image effect demo (sorting)
npm无法安装sharp
Chapter 19 using work queue manager (2)
dockermysql修改root账号密码并赋予权限
mysql拆分字符串作为查询条件的示例代码
OpenNMS separation database
Aardio - does not declare the method of directly passing float values
关于声子和热输运计算中BORN电荷和non-analytic修正的问题
欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质
QT信号和槽
Jafka来源分析——Processor