当前位置:网站首页>(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)
边栏推荐
- 机试刷题1
- OpenSSL: a full-featured toolkit for TLS and SSL protocols, and a general encryption library
- 视图(view)
- DockerMySQL无法被宿主机访问的问题解决
- MySQL authentication bypass vulnerability (cve-2012-2122)
- CRMEB商城系统如何助力营销?
- NPM cannot install sharp
- C# 三种方式实现Socket数据接收
- 【无标题】
- ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
猜你喜欢
![[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files](/img/08/1636ae909e7cc70ddf975d2e3122cd.png)
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files

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

CUDA exploration

2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9

【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件

Custom swap function

CocosCreator+TypeScripts自己写一个对象池

Matlab tips (27) grey prediction

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

UE4 blueprint learning chapter (IV) -- process control forloop and whileloop
随机推荐
存币生息理财dapp系统开发案例演示
[IELTS speaking] Anna's oral learning record part1
OpenNMS separation database
The ceiling of MySQL tutorial. Collect it and take your time
Aardio - construct a multi button component with customplus library +plus
动作捕捉用于蛇运动分析及蛇形机器人开发
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
memcached
#DAYU200体验官# 在DAYU200运行基于ArkUI-eTS的智能晾晒系统页面
Adavit -- dynamic network with adaptive selection of computing structure
View
Export MySQL table data in pure mode
欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质
Bipartite graph determination
POJ 1258 Agri-Net
Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
Financial professionals must read book series 6: equity investment (based on the outline and framework of the CFA exam)
mysql拆分字符串作为查询条件的示例代码
#DAYU200体验官# 首页aito视频&Canvas绘制仪表盘(ets)
2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9