6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 10cfcfe0

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-05-14 13:30:31 +0200
Added environment check in main file

Changed files

comwell_key_app/lib/main.dart | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Diff

diff --git a/comwell_key_app/lib/main.dart b/comwell_key_app/lib/main.dart
index 15f5c7e2..7ecefcd4 100644
--- a/comwell_key_app/lib/main.dart
+++ b/comwell_key_app/lib/main.dart
@@ -12,7 +12,27 @@ import 'comwell_app.dart';
void runMainApp(FirebaseOptions firebaseOptions) async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
- await dotenv.load(fileName: ".env");
+ // Load the appropriate .env file based on the flavor
+ String envFile = '.env';
+ if (appFlavor == 'develop') {
+ envFile = '.env.dev';
+ } else if (appFlavor == 'stage') {
+ envFile = '.env.stage';
+ } else if (appFlavor == 'prod') {
+ envFile = '.env.prod';
+ }
+
+ debugPrint("Current flavor: $appFlavor");
+ debugPrint("Loading environment file: $envFile");
+
+ try {
+ await dotenv.load(fileName: '.env');
+ debugPrint("Successfully loaded environment file");
+ } catch (e) {
+ debugPrint("Error loading environment file: $e");
+ rethrow;
+ }
+
await configureFirebase();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
setupLocator();