Skip to content

Commit

Permalink
Instuctions to install ErrorListener on Isolate (firebase#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdoom authored Jul 1, 2020
1 parent 9c5d05d commit 6f3183b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/firebase_crashlytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,18 @@ runZoned<Future<void>>(() async {
// ...
}, onError: Crashlytics.instance.recordError);
```
With Flutter 1.17 which includes Dart 2.8, use runZonedGuarded instead:

Finally, to catch errors that happen outside Flutter context, install an error
listener on the current Isolate:

```dart
runZonedGuarded<Future<void>>(() async {
// ...
}, onError: Crashlytics.instance.recordError);
Isolate.current.addErrorListener(RawReceivePort((pair) async {
final List<dynamic> errorAndStacktrace = pair;
await Crashlytics.instance.recordError(
errorAndStacktrace.first,
errorAndStacktrace.last,
);
}).sendPort);
```

## Result
Expand Down

0 comments on commit 6f3183b

Please sign in to comment.