mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2025-12-22 01:20:46 +00:00
init
This commit is contained in:
27
lib/runner/errors_handlers.dart
Normal file
27
lib/runner/errors_handlers.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
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(),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user