Skip to content

Commit

Permalink
Generate a random exception at boot and send to err trackers
Browse files Browse the repository at this point in the history
  • Loading branch information
kitallis committed May 19, 2024
1 parent 1169a45 commit 2b4a552
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:ui';
import 'dart:math';
import 'firebase_options.dart';
import 'package:drop_shadow/drop_shadow.dart';
import 'package:firebase_core/firebase_core.dart';
Expand All @@ -11,8 +12,10 @@ import 'package:bugsnag_flutter/bugsnag_flutter.dart';

Future<void> main() async {
await bugsnag.start(
apiKey: const String.fromEnvironment('BUGSNAG_API_KEY', defaultValue: 'dummy'),
apiKey:
const String.fromEnvironment('BUGSNAG_API_KEY', defaultValue: 'dummy'),
);

await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
Expand All @@ -27,9 +30,25 @@ Future<void> main() async {
return true;
};

try {
randomException();
} catch (e, stack) {
bugsnag.notify(e, stack);
await FirebaseCrashlytics.instance
.recordError(e, stack, reason: 'a fake, generated non-fatal err');
}

runApp(const App());
}

void randomException() {
final random = Random();
if (random.nextBool()) {
throw Exception(
'dis exception was randomly generated to fill up ur error trackerz');
}
}

class App extends StatefulWidget {
const App({Key? key}) : super(key: key);

Expand Down Expand Up @@ -284,7 +303,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Image.asset(coverImage, width: 150.0)),
padding: const EdgeInsets.all(10.0),
subtitle:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Padding(
padding: const EdgeInsets.only(bottom: 1),
child: Text(stationDistanceBetween,
Expand All @@ -303,7 +322,7 @@ class _MyHomePageState extends State<MyHomePage> {
color: textColor())))
]),
additionalInfo:
Column(crossAxisAlignment: CrossAxisAlignment.end, children: [
Column(crossAxisAlignment: CrossAxisAlignment.end, children: [
Padding(
padding: const EdgeInsets.only(bottom: 1),
child: Text(stationNameEn,
Expand All @@ -323,7 +342,7 @@ class _MyHomePageState extends State<MyHomePage> {
color: textColor()))),
...List.generate(
shinkansens.length,
(index) => DropShadow(
(index) => DropShadow(
blurRadius: 0.2,
borderRadius: 0,
spread: 1,
Expand Down

0 comments on commit 2b4a552

Please sign in to comment.