kwithDoubleClickExit method
包裹 双击 退出
Implementation
Widget kwithDoubleClickExit(Function tip, {bool isWrapWillPop = true}) {
bool isExit = false;
return isWrapWillPop
? WillPopScope(
child: this,
onWillPop: () async {
if (!isExit) {
isExit = true;
tip();
//2秒内没有点击 isExit 从新置为false
Future.delayed(const Duration(milliseconds: 2000), () {
isExit = false;
});
return false;
} else {
// 退出app
return true;
}
})
: this;
}