This repository was archived by the owner on Dec 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathfatal_crashes_content.dart
More file actions
95 lines (92 loc) · 3.52 KB
/
fatal_crashes_content.dart
File metadata and controls
95 lines (92 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
part of '../../main.dart';
class FatalCrashesContent extends StatelessWidget {
const FatalCrashesContent({Key? key}) : super(key: key);
void throwUnhandledException(dynamic error) {
if (error is! Error) {
const appName = 'Flutter Test App';
final errorMessage = error?.toString() ?? 'Unknown Error';
error = Exception('Unhandled Error: $errorMessage from $appName');
}
throw error;
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
InstabugButton(
symanticLabel: 'fatal_crash_exception',
text: 'Throw Exception',
key: const Key('fatal_crash_exception'),
onPressed: () => throwUnhandledException(
Exception('This is a generic exception.')),
),
InstabugButton(
symanticLabel: 'fatal_crash_state_exception',
text: 'Throw StateError',
key: const Key('fatal_crash_state_exception'),
onPressed: () =>
throwUnhandledException(StateError('This is a StateError.')),
),
InstabugButton(
symanticLabel: 'fatal_crash_argument_exception',
text: 'Throw ArgumentError',
key: const Key('fatal_crash_argument_exception'),
onPressed: () => throwUnhandledException(
ArgumentError('This is an ArgumentError.')),
),
InstabugButton(
symanticLabel: 'fatal_crash_range_exception',
text: 'Throw RangeError',
key: const Key('fatal_crash_range_exception'),
onPressed: () => throwUnhandledException(
RangeError.range(5, 0, 3, 'Index out of range')),
),
InstabugButton(
symanticLabel: 'fatal_crash_format_exception',
text: 'Throw FormatException',
key: const Key('fatal_crash_format_exception'),
onPressed: () =>
throwUnhandledException(UnsupportedError('Invalid format.')),
),
InstabugButton(
symanticLabel: 'fatal_crash_no_such_method_error_exception',
text: 'Throw NoSuchMethodError',
key: const Key('fatal_crash_no_such_method_error_exception'),
onPressed: () {
// This intentionally triggers a NoSuchMethodError
dynamic obj;
throwUnhandledException(obj.methodThatDoesNotExist());
},
),
InstabugButton(
symanticLabel: 'fatal_crash_native_exception',
text: 'Throw Native Fatal Crash',
key: const Key('fatal_crash_native_exception'),
onPressed: InstabugFlutterExampleMethodChannel.sendNativeFatalCrash,
),
InstabugButton(
symanticLabel: 'fatal_crash_native_hang',
text: 'Send Native Fatal Hang',
key: const Key('fatal_crash_native_hang'),
onPressed: InstabugFlutterExampleMethodChannel.sendNativeFatalHang,
),
Platform.isAndroid
? InstabugButton(
symanticLabel: 'fatal_crash_anr',
text: 'Send Native ANR',
key: const Key('fatal_crash_anr'),
onPressed: InstabugFlutterExampleMethodChannel.sendAnr,
)
: const SizedBox.shrink(),
InstabugButton(
symanticLabel: 'fatal_crash_oom',
text: 'Throw Unhandled Native OOM Exception',
key: const Key('fatal_crash_oom'),
onPressed: InstabugFlutterExampleMethodChannel.sendOom,
),
],
);
}
}