Skip to content

Commit a78f508

Browse files
committed
🚀 feat(main.dart): add support for recording uncaught asynchronous errors to Firebase Crashlytics.
1 parent 203cb8d commit a78f508

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎lib/main.dart‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ void main() async {
5252
// Pass all uncaught errors from the framework to Crashlytics.
5353
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
5454

55+
// Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics
56+
PlatformDispatcher.instance.onError = (error, stack) {
57+
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
58+
return true;
59+
};
60+
5561
// Disable analytics & crashlytics when in debug mode
5662
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(!kDebugMode);
5763
FirebaseAnalytics.instance.setAnalyticsCollectionEnabled(!kDebugMode);

0 commit comments

Comments
 (0)