main function

void main()

Implementation

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final logger = LoggerService();

  // --- SECURE GLOBAL ERROR HANDLING ---

  // Catch errors in the Flutter framework
  FlutterError.onError = (details) {
    FlutterError.presentError(details);
    _reportError(logger, details.exception, details.stack);
  };

  // Catch errors in the underlying platform (asynchronous errors)
  PlatformDispatcher.instance.onError = (error, stack) {
    _reportError(logger, error, stack);
    return true;
  };

  final prefs = await SharedPreferences.getInstance();
  const secureStorage = FlutterSecureStorage();

  runApp(
    ProviderScope(
      observers: [AppProviderObserver(logger)],
      overrides: [
        storageServiceProvider.overrideWithValue(StorageService(prefs, secureStorage)),
      ],
      child: const MyApp(),
    ),
  );
}