From dff03796e9799d62a2cb33637b8c8283d8901d9b Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 3 Dec 2024 11:17:42 +0300 Subject: [PATCH] Crashlytics enabled --- lib/main.dart | 12 ++++++++++++ lib/splashPage.dart | 2 ++ pubspec.yaml | 1 + 3 files changed, 15 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index a0a584a5..7bf71077 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,6 +14,8 @@ import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; @@ -27,6 +29,16 @@ import 'pages/pharmacies/compare-list.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); + + // Pass all uncaught "fatal" errors from the framework to Crashlytics + FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; + + // Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics + PlatformDispatcher.instance.onError = (error, stack) { + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + return true; + }; + setupLocator(); HttpOverrides.global = MyHttpOverrides(); runApp(MyApp()); diff --git a/lib/splashPage.dart b/lib/splashPage.dart index 515c7f54..7743cd73 100644 --- a/lib/splashPage.dart +++ b/lib/splashPage.dart @@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/uitl/LocalNotification.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/push-notification-handler.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart'; @@ -84,6 +85,7 @@ class _SplashScreenState extends State { // debugPrint("ALL SHARED PREFERENCES!!!!!"); // debugPrint(jsonEncode(value)); }); + await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); // PushNotificationHandler(context).init(); // Asyncronously } diff --git a/pubspec.yaml b/pubspec.yaml index 53123f35..7b43a711 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -183,6 +183,7 @@ dependencies: win32: ^5.5.4 cloudflare_turnstile: ^2.0.1 + firebase_crashlytics: ^3.0.0 dependency_overrides: