Created
March 19, 2024 09:09
-
-
Save RobertApikyan/468bb2c9a7c803b202dd319ce0a085f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:io'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:good_car/app.dart'; | |
import 'package:good_car/repositories/app_repo.dart'; | |
import 'package:good_car/tools/Instance_id.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
import 'package:version/version.dart'; | |
final dev = AppEnvironment( | |
name: 'dev', | |
domain: 'goodcar.com', | |
goodCarApiUrl: 'https://goodcar.com', | |
infoPayApiUrl: 'http://api1.infopay.net', | |
crashReportingEnabled: kReleaseMode); | |
final prod = AppEnvironment( | |
name: 'prod', | |
domain: 'goodcar.com', | |
infoPayApiUrl: 'http://api1.infopay.net', | |
goodCarApiUrl: 'https://goodcar.com', | |
crashReportingEnabled: kReleaseMode); | |
class AppEnvironment { | |
AppEnvironment({ | |
required this.name, | |
required this.domain, | |
required this.infoPayApiUrl, | |
required this.goodCarApiUrl, | |
required this.crashReportingEnabled, | |
}); | |
static late AppEnvironment instance; | |
final String domain; | |
final String goodCarApiUrl; | |
final String infoPayApiUrl; | |
final bool crashReportingEnabled; | |
final String name; | |
late final String instanceId; | |
late final String storeUrl = Platform.isIOS | |
? "https://apps.apple.com/ng/app/life-field-recorder/<ADD_APPLE_STORE_LINK>" | |
: "https://play.google.com/store/apps/details?id=com.goodcar"; | |
late final Directory cacheDirectory; | |
late final Version currentVersion; | |
String get versionInfo => instance == prod | |
? 'v$currentVersion' | |
: 'v$currentVersion ${name.toUpperCase()}'; | |
void call() => runZonedGuarded<Future<void>>(() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
AppEnvironment.instance = this; | |
// final ii = ; | |
//TODO(@Apikyan): remove .dispose() | |
// await ii.dispose(); | |
instanceId = await InstanceId().get(); | |
cacheDirectory = await getApplicationCacheDirectory(); | |
currentVersion = await AppRepo.currentVersion(); | |
// await Firebase.initializeApp( | |
// options: DefaultFirebaseOptions.currentPlatform); | |
if (crashReportingEnabled) { | |
// FlutterError.onError = | |
// FirebaseCrashlytics.instance.recordFlutterError; | |
} | |
runApp(const App()); | |
}, (error, stack) { | |
if (crashReportingEnabled) { | |
// FirebaseCrashlytics.instance | |
// .recordError(error, stack, printDetails: true); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment