Skip to content

crashlytics_monitoring_impl Free

Firebase Crashlytics vendor implementation for monitoring_api.

Version: 1.0.0

Variables

VariableTypeDefaultDescription
appNamestringThe name of your application
isForMonorepobooleantrueWhether 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 provider

Key Features

  • Crash collection toggleinitialize(enable:) calls setCrashlyticsCollectionEnabled so collection is opt-in and can be disabled (e.g. for users who decline analytics consent)
  • User identitysetUserId maps to Crashlytics setUserIdentifier and stores optional email and token as custom keys
  • Breadcrumb logginglog(message:, tag:) formats as [tag] message and sends via crashlytics.log
  • Fatal vs non-fatal errorsrecordError forwards to recordFlutterFatalError or recordError depending on the fatal flag; sets printDetails: kDebugMode
  • Flutter error capture — Exposes recordFlutterError(FlutterErrorDetails) for hooking into FlutterError.onError
  • No transaction support — Crashlytics has no performance tracing API; recordTransaction is a no-op that still invokes the provided function

Dependencies

PackageVersionPurpose
firebase_crashlyticsany (workspace)Firebase Crashlytics SDK
monitoring_apipathAppMonitoring contract
dependenciespathinjectable / get_it re-export

Configuration

Firebase Crashlytics requires native setup before the Dart package works:

  1. Add google-services.json (Android) and GoogleService-Info.plist (iOS) to the respective platform directories
  2. Apply the google-services Gradle plugin in Android
  3. 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.

dart
// 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);

Built by Banua Coder