21 lines
555 B
Dart
21 lines
555 B
Dart
import 'dart:io';
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
import 'package:get/get.dart';
|
|
import 'state.dart';
|
|
|
|
class LoginLogic extends GetxController {
|
|
final LoginState state = LoginState();
|
|
|
|
void isExit(context) {
|
|
if (state.lastPressedAt == null ||
|
|
DateTime.now().difference(state.lastPressedAt!) >
|
|
const Duration(seconds: 1)) {
|
|
//两次点击间隔超过1秒则重新计时
|
|
state.lastPressedAt = DateTime.now();
|
|
BotToast.showText(text:"再按一次退出程序");
|
|
return;
|
|
}
|
|
exit(0);
|
|
}
|
|
}
|