mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +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:
@@ -40,14 +40,15 @@ Future<void> guardWithCrashlytics(
|
|||||||
crashlytics?.log(message);
|
crashlytics?.log(message);
|
||||||
|
|
||||||
if (record.level >= Level.SEVERE) {
|
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.
|
// Pass all uncaught errors from the framework to Crashlytics.
|
||||||
if (crashlytics != null) {
|
if (crashlytics != null) {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
FlutterError.onError = crashlytics.recordFlutterError;
|
FlutterError.onError = crashlytics.recordFlutterFatalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
@@ -56,9 +57,8 @@ Future<void> guardWithCrashlytics(
|
|||||||
Isolate.current.addErrorListener(RawReceivePort((dynamic pair) async {
|
Isolate.current.addErrorListener(RawReceivePort((dynamic pair) async {
|
||||||
final errorAndStacktrace = pair as List<dynamic>;
|
final errorAndStacktrace = pair as List<dynamic>;
|
||||||
await crashlytics?.recordError(
|
await crashlytics?.recordError(
|
||||||
errorAndStacktrace.first,
|
errorAndStacktrace.first, errorAndStacktrace.last as StackTrace?,
|
||||||
errorAndStacktrace.last as StackTrace?,
|
fatal: true);
|
||||||
);
|
|
||||||
}).sendPort);
|
}).sendPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ Future<void> guardWithCrashlytics(
|
|||||||
// This sees all errors that occur in the runZonedGuarded zone.
|
// This sees all errors that occur in the runZonedGuarded zone.
|
||||||
debugPrint('ERROR: $error\n\n'
|
debugPrint('ERROR: $error\n\n'
|
||||||
'STACK:$stack');
|
'STACK:$stack');
|
||||||
crashlytics?.recordError(error, stack);
|
crashlytics?.recordError(error, stack, fatal: true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user