From 597d441ffdff38fb2506a78500a372f6ab0b3580 Mon Sep 17 00:00:00 2001 From: LezdCS Date: Thu, 16 May 2024 19:10:15 +0900 Subject: [PATCH] Link talker to crashlytics --- lib/main.dart | 3 +++ .../utils/crashlytics_talker_observer.dart | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 lib/src/core/utils/crashlytics_talker_observer.dart diff --git a/lib/main.dart b/lib/main.dart index 13499aa1..5a6335f5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,7 @@ import 'package:get_storage/get_storage.dart'; import 'package:irllink/routes/app_pages.dart'; import 'package:irllink/src/bindings/login_bindings.dart'; import 'package:irllink/src/core/resources/themes.dart'; +import 'package:irllink/src/core/utils/crashlytics_talker_observer.dart'; import 'package:irllink/src/presentation/views/login_view.dart'; import 'package:kick_chat/kick_chat.dart'; import 'package:package_info_plus/package_info_plus.dart'; @@ -23,8 +24,10 @@ import 'src/core/utils/globals.dart' as globals; void main() async { WidgetsFlutterBinding.ensureInitialized(); + final crashlyticsTalkerObserver = CrashlyticsTalkerObserver(); final talker = TalkerFlutter.init( settings: TalkerSettings(), + observer: crashlyticsTalkerObserver, ); await initializeService(); await GetStorage.init(); diff --git a/lib/src/core/utils/crashlytics_talker_observer.dart b/lib/src/core/utils/crashlytics_talker_observer.dart new file mode 100644 index 00000000..2fe4d48f --- /dev/null +++ b/lib/src/core/utils/crashlytics_talker_observer.dart @@ -0,0 +1,24 @@ +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; +import 'package:talker_flutter/talker_flutter.dart'; + +class CrashlyticsTalkerObserver extends TalkerObserver { + CrashlyticsTalkerObserver(); + + @override + void onError(err) { + FirebaseCrashlytics.instance.recordError( + err.error, + err.stackTrace, + reason: err.message, + ); + } + + @override + void onException(err) { + FirebaseCrashlytics.instance.recordError( + err.exception, + err.stackTrace, + reason: err.message, + ); + } +} \ No newline at end of file