passo_mobile_app/lib/screens/unit2/login/functions/press-again-to-exit.dart

20 lines
539 B
Dart
Raw Permalink Normal View History

2023-01-23 08:43:02 +00:00
2022-11-28 08:03:13 +00:00
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
Future<bool> pressAgainToExit() async {
DateTime? currentBackPressTime;
DateTime now = DateTime.now();
if (currentBackPressTime == null ||
now.difference(currentBackPressTime) > const Duration(seconds: 1)) {
currentBackPressTime = now;
Fluttertoast.showToast(
msg: "Press again to exit",
gravity: ToastGravity.CENTER,
backgroundColor: Colors.black);
return Future.value(false);
}
return true;
}