![](https://keeplearning.dev/images/featured/warp-terminal.png)
PHP
My notes about Firebase Crashlytics in the Flutter application.
Firebase Crashlytics is a crash reporting and analysis service provided by Google as part of the Firebase suite of app development tools.
It helps developers track, prioritize, and fix stability issues in mobile applications. When an app crashes, Firebase Crashlytics captures and logs information about the crash, providing developers with detailed reports to understand the root causes of the issues.
Firebase Crashlytics offers several advantages that streamline the process of identifying and resolving crashes in mobile applications.
Here’s an overview of key benefits:
In summary, Firebase Crashlytics enhances the development and maintenance process by offering features that simplify crash identification, debugging, and resolution.
The platform’s real-time capabilities and integration with visualization tools contribute to a more efficient and proactive approach to managing app stability.
At to root of your project run;
flutter pub add firebase_crashlytics
Then run;
flutterfire configure
If you didn’t install FlutterFire CLI please check it out here.
After that run your application.
In the second step, we need to configure the crash handlers. Open your project main and override the FlutterError.onError with FirebaseCrashlytics.instance.recordFlutterFatalError.
Also for catching asynchronous errors use PlatformDispatcher.instance.onError.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FlutterError.onError = (errorDetails) {
FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails);
};
PlatformDispatcher.instance.onError = (error, stack) {
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
return true;
};
runApp(MyApp());
}
To finish setting up Crashlytics and see initial data add this code anywhere in your application.
TextButton(
onPressed: () => throw Exception(),
child: const Text("Throw Test Exception"),
),
Then run this code block after the build. That is all. Then you will be able to see logs in your project.