Prevent multiple UI errors from showing multiple alerts [skip ci]

This commit is contained in:
OmarHatem 2023-01-27 03:49:25 +02:00
parent 194902d8cb
commit ae0f9df041

View file

@ -50,6 +50,7 @@ import 'package:cake_wallet/wallet_type_utils.dart';
final navigatorKey = GlobalKey<NavigatorState>();
final rootKey = GlobalKey<RootState>();
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
bool hasError = false;
Future<void> main() async {
@ -206,11 +207,16 @@ void _sendExceptionFile() async {
}
void _onError(FlutterErrorDetails errorDetails) {
if (hasError) {
return;
}
hasError = true;
_saveException(errorDetails.exception.toString(), errorDetails.stack);
WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) {
showPopUp<void>(
(timeStamp) async {
await showPopUp<void>(
context: navigatorKey.currentContext!,
builder: (context) {
return AlertWithTwoActions(
@ -229,6 +235,8 @@ void _onError(FlutterErrorDetails errorDetails) {
);
},
);
hasError = false;
},
);
}