checkDoubleBackExit static method
Double back exit logic
Implementation
static Future<bool> checkDoubleBackExit(
BuildContext context,
Duration timeout,
String? message,
) async {
final now = DateTime.now();
if (_lastBackPress == null || now.difference(_lastBackPress!) > timeout) {
_lastBackPress = now;
if (message != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), duration: timeout),
);
}
return false; // prevent exit
}
return true; // allow exit
}