mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2025-12-22 09:30:45 +00:00
28 lines
966 B
Dart
28 lines
966 B
Dart
part of 'app_runner.dart';
|
|
|
|
/// Метод инициализации обработчиков ошибок
|
|
void _initErrorHandlers(IDebugService debugService) {
|
|
// Обработка ошибок в приложении
|
|
FlutterError.onError = (details) {
|
|
_showErrorScreen();
|
|
debugService.handleError(details.exception, details.stack,
|
|
'FlutterError.onError: ${details.exceptionAsString()}',);
|
|
};
|
|
// Обработка асинхронных ошибок в приложении
|
|
PlatformDispatcher.instance.onError = (error, stack) {
|
|
_showErrorScreen();
|
|
debugService.handleError(error, stack, 'PlatformDispatcher: $error');
|
|
return true;
|
|
};
|
|
}
|
|
/// Метод для показа экрана ошибки
|
|
void _showErrorScreen() {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
AppRouter.rootNavigatorKey.currentState?.push(
|
|
MaterialPageRoute(
|
|
builder: (_) => const ErrorScreen(),
|
|
),
|
|
);
|
|
});
|
|
}
|