@@ -87,39 +87,41 @@ Instabug automatically captures every crash of your app and sends relevant detai
87
87
⚠️ ** Crashes will only be reported in release mode and not in debug mode.**
88
88
89
89
90
- 1 . To start using Crash reporting, import the following into your ` main.dart ` .
90
+ 1 . Import the following into your ` main.dart ` :
91
91
92
92
``` dart
93
93
import 'package:instabug_flutter/CrashReporting.dart';
94
94
```
95
95
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
+ ```
123
125
124
126
## Repro Steps
125
127
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