m3_lightmeter/lib/runner.dart

48 lines
1.7 KiB
Dart
Raw Permalink Normal View History

import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/widgets.dart';
2024-11-01 09:42:41 +00:00
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:lightmeter/application.dart';
import 'package:lightmeter/application_wrapper.dart';
import 'package:lightmeter/constants.dart';
import 'package:lightmeter/data/analytics/analytics.dart';
import 'package:lightmeter/data/analytics/api/analytics_firebase.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/firebase_options.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
const _errorsLogger = LightmeterAnalytics(api: LightmeterAnalyticsFirebase());
Future<void> runLightmeterApp(Environment env) async {
runZonedGuarded(
() async {
2024-11-01 09:42:41 +00:00
final widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
if (env.buildType == BuildType.prod) {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
}
_errorsLogger.init();
final application = ApplicationWrapper(env, child: const Application());
runApp(
env.buildType == BuildType.dev
? IAPProducts(
products: [
IAPProduct(
storeId: IAPProductType.paidFeatures.storeId,
2024-11-01 09:42:41 +00:00
status: IAPProductStatus.purchased,
price: '0.0\$',
),
],
child: application,
)
: IAPProductsProvider(
apiUrl: iapServerUrl,
child: application,
),
);
},
_errorsLogger.logCrash,
);
}