diff --git a/lib/main.dart b/lib/main.dart index 06c2a135..0d80171f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,6 +25,19 @@ import 'package:shared_preferences/shared_preferences.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + + // Pass all uncaught "fatal" errors from the framework to Crashlytics + FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; + + // Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics + PlatformDispatcher.instance.onError = (error, stack) { + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + return true; + }; + final prefs = await SharedPreferences.getInstance(); final firstRun = prefs.getBool('first_run') ?? true; @@ -48,19 +61,6 @@ void main() async { // Create a MobX reaction that will save the settings on disk every time they are changed. autorun((_) => prefs.setString('settings', jsonEncode(settingsStore))); - await Firebase.initializeApp( - options: DefaultFirebaseOptions.currentPlatform, - ); - - // Pass all uncaught "fatal" errors from the framework to Crashlytics - FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; - - // Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics - PlatformDispatcher.instance.onError = (error, stack) { - FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); - return true; - }; - /// Initialize API services with a common client. /// This will prevent every request from creating a new client instance. final client = Client();