crashlytics_monitoring_impl Free
Firebase Crashlytics vendor implementation for
monitoring_api.
Version: 1.0.0
Variables
| Variable | Type | Default | Description |
|---|---|---|---|
| appName | string | — | The name of your application |
| isForMonorepo | boolean | true | Whether this is being generated as part of a monorepo |
Architecture
crashlytics_monitoring_impl is a vendor brick that implements the AppMonitoring contract from monitoring_api using Firebase Crashlytics. It is selected during flutter_modular_monorepo generation when the user picks crashlytics from the monitoringVendors multi-select.
The implementation wraps FirebaseCrashlytics.instance which is provided to DI via CrashlyticsRegisterModule. The instance is registered as a @LazySingleton named MonitoringInjectorKey.crashlyticsImpl and bound to the AppMonitoring interface.
DI Registration
The package uses @InjectableInit.microPackage() for modular registration. The host app imports CrashlyticsMonitoringImplPackageModule and calls initCrashlyticsMonitoringImplModule() during DI bootstrap.
Generated Structure
infrastructure/
└── crashlytics_monitoring_impl/
├── pubspec.yaml
└── lib/
├── crashlytics_monitoring_impl.dart # Barrel export
└── src/
├── crashlytics_monitoring_impl.dart # AppMonitoring impl
└── di/
├── injector.dart # microPackage init
├── injector.module.dart # Generated DI module
└── register_module.dart # FirebaseCrashlytics providerKey Features
- Crash collection toggle —
initialize(enable:)callssetCrashlyticsCollectionEnabledso collection is opt-in and can be disabled (e.g. for users who decline analytics consent) - User identity —
setUserIdmaps to CrashlyticssetUserIdentifierand stores optionalemailandtokenas custom keys - Breadcrumb logging —
log(message:, tag:)formats as[tag] messageand sends viacrashlytics.log - Fatal vs non-fatal errors —
recordErrorforwards torecordFlutterFatalErrororrecordErrordepending on thefatalflag; setsprintDetails: kDebugMode - Flutter error capture — Exposes
recordFlutterError(FlutterErrorDetails)for hooking intoFlutterError.onError - No transaction support — Crashlytics has no performance tracing API;
recordTransactionis a no-op that still invokes the provided function
Dependencies
| Package | Version | Purpose |
|---|---|---|
firebase_crashlytics | any (workspace) | Firebase Crashlytics SDK |
monitoring_api | path | AppMonitoring contract |
dependencies | path | injectable / get_it re-export |
Configuration
Firebase Crashlytics requires native setup before the Dart package works:
- Add
google-services.json(Android) andGoogleService-Info.plist(iOS) to the respective platform directories - Apply the
google-servicesGradle plugin in Android - Enable Crashlytics in the Firebase console for the project
No Dart-level config class is needed — FirebaseCrashlytics.instance is used directly and is provided by the CrashlyticsRegisterModule.
// In your app DI module, override nothing — FirebaseCrashlytics.instance
// is registered automatically by CrashlyticsRegisterModule.
// Toggle collection based on user consent:
final monitoring = getIt<AppMonitoring>(
instanceName: MonitoringInjectorKey.crashlyticsImpl,
);
await monitoring.initialize(enable: userConsentGranted);