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