2023-09-03 11:06:30 +00:00
|
|
|
import 'dart:developer';
|
|
|
|
|
2023-05-03 10:45:10 +00:00
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
|
|
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
2023-05-11 13:30:18 +00:00
|
|
|
import 'package:lightmeter/firebase_options.dart';
|
2023-05-03 10:45:10 +00:00
|
|
|
|
2023-09-03 11:06:30 +00:00
|
|
|
Future<void> initializeFirebase({required bool handleErrors}) async {
|
|
|
|
try {
|
|
|
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
|
|
if (handleErrors) {
|
|
|
|
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
|
|
|
|
PlatformDispatcher.instance.onError = (error, stack) {
|
|
|
|
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
log(e.toString());
|
|
|
|
}
|
2023-05-03 10:45:10 +00:00
|
|
|
}
|