1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

New Crashlytics Crash Reporting APIs (#1351)

* Changes to package import statements

Without these changes to the package import statements, if a user uncomments the FirebaseCrashlytics code, they will get a bunch of errors.

* Commented out import statements & added instructions

* Update crashlytics.dart

Upgrade Crashlytics.dart to use recently released fatal crash APIs
https://firebase.blog/posts/2022/07/whats-new-in-crashlytics-for-flutter

* Ran dart format on changed files
This commit is contained in:
Rich Hall
2022-07-29 07:24:20 +10:00
committed by GitHub
parent 1594d74199
commit 1de97a68d4

View File

@@ -40,14 +40,15 @@ Future<void> guardWithCrashlytics(
crashlytics?.log(message);
if (record.level >= Level.SEVERE) {
crashlytics?.recordError(message, filterStackTrace(StackTrace.current));
crashlytics?.recordError(message, filterStackTrace(StackTrace.current),
fatal: true);
}
});
// Pass all uncaught errors from the framework to Crashlytics.
if (crashlytics != null) {
WidgetsFlutterBinding.ensureInitialized();
FlutterError.onError = crashlytics.recordFlutterError;
FlutterError.onError = crashlytics.recordFlutterFatalError;
}
if (!kIsWeb) {
@@ -56,9 +57,8 @@ Future<void> guardWithCrashlytics(
Isolate.current.addErrorListener(RawReceivePort((dynamic pair) async {
final errorAndStacktrace = pair as List<dynamic>;
await crashlytics?.recordError(
errorAndStacktrace.first,
errorAndStacktrace.last as StackTrace?,
);
errorAndStacktrace.first, errorAndStacktrace.last as StackTrace?,
fatal: true);
}).sendPort);
}
@@ -68,7 +68,7 @@ Future<void> guardWithCrashlytics(
// This sees all errors that occur in the runZonedGuarded zone.
debugPrint('ERROR: $error\n\n'
'STACK:$stack');
crashlytics?.recordError(error, stack);
crashlytics?.recordError(error, stack, fatal: true);
});
}