Skip to content

Commit 2180762

Browse files
Ali AbdelfattahAliAbdelfattah
authored andcommitted
Update README.md
1 parent 01759df commit 2180762

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,39 +87,41 @@ Instabug automatically captures every crash of your app and sends relevant detai
8787
⚠️ **Crashes will only be reported in release mode and not in debug mode.**
8888

8989

90-
1. To start using Crash reporting, import the following into your `main.dart`.
90+
1. Import the following into your `main.dart`:
9191

9292
```dart
9393
import 'package:instabug_flutter/CrashReporting.dart';
9494
```
9595

96-
2. Replace `void main() => runApp(MyApp());` with the following snippet:
97-
```dart
98-
void main() async {
99-
FlutterError.onError = (FlutterErrorDetails details) {
100-
Zone.current.handleUncaughtError(details.exception, details.stack);
101-
};
102-
runZoned<Future<void>>(() async {
103-
runApp(MyApp());
104-
}, onError: (dynamic error, StackTrace stackTrace) {
105-
CrashReporting.reportCrash(error, stackTrace);
106-
});
107-
}
108-
```
109-
110-
With Flutter 1.17 use this snipped instead:
111-
```dart
112-
void main() async {
113-
FlutterError.onError = (FlutterErrorDetails details) {
114-
Zone.current.handleUncaughtError(details.exception, details.stack);
115-
};
116-
runZonedGuarded<Future<void>>(() async {
117-
runApp(CrashyApp());
118-
}, (Object error, StackTrace stackTrace) {
119-
CrashReporting.reportCrash(error, stackTrace);
120-
});
121-
}
122-
```
96+
2. Replace `void main() => runApp(MyApp());` with the following snippet.
97+
98+
Recommended:
99+
```dart
100+
void main() async {
101+
FlutterError.onError = (FlutterErrorDetails details) {
102+
Zone.current.handleUncaughtError(details.exception, details.stack);
103+
};
104+
runZonedGuarded<Future<void>>(() async {
105+
runApp(MyApp());
106+
}, (Object error, StackTrace stackTrace) {
107+
CrashReporting.reportCrash(error, stackTrace);
108+
});
109+
}
110+
```
111+
112+
For Flutter versions prior to 1.17:
113+
```dart
114+
void main() async {
115+
FlutterError.onError = (FlutterErrorDetails details) {
116+
Zone.current.handleUncaughtError(details.exception, details.stack);
117+
};
118+
runZoned<Future<void>>(() async {
119+
runApp(MyApp());
120+
}, onError: (dynamic error, StackTrace stackTrace) {
121+
CrashReporting.reportCrash(error, stackTrace);
122+
});
123+
}
124+
```
123125

124126
## Repro Steps
125127
Repro Steps list all of the actions an app user took before reporting a bug or crash, grouped by the screens they visited in your app.

0 commit comments

Comments
 (0)