Skip to content

Commit

Permalink
chore(#475): force supabase env values
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesvedder committed Jul 5, 2023
1 parent fce67b1 commit 55bfa31
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions flutter_common/lib/src/utils/env_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ String envFilePath() {
return env.isNotEmpty ? '$envsAssetPath/$env' : '$envsAssetPath/.env';
}

String? getEnv(String name) {
return dotenv.env[name] ?? (bool.hasEnvironment(name) ? String.fromEnvironment(name) : null);
}

Future<void> loadEnv() async {
await dotenv.load(fileName: envFilePath());
final supabaseUrl = dotenv.env['STUDYU_SUPABASE_URL'] ?? const String.fromEnvironment('STUDYU_SUPABASE_URL');
final supabaseAnonKey =
dotenv.env['STUDYU_SUPABASE_PUBLIC_ANON_KEY'] ?? const String.fromEnvironment('STUDYU_SUPABASE_PUBLIC_ANON_KEY');
final envAppUrl = dotenv.env['STUDYU_APP_URL'] ?? const String.fromEnvironment('STUDYU_APP_URL');
final envDesignerUrl = dotenv.env['STUDYU_DESIGNER_URL'] ?? const String.fromEnvironment('STUDYU_DESIGNER_URL');
final envProjectGeneratorUrl =
dotenv.env['STUDYU_PROJECT_GENERATOR_URL'] ?? const String.fromEnvironment('STUDYU_PROJECT_GENERATOR_URL');
final supabaseUrl = getEnv('STUDYU_SUPABASE_URL');
final supabaseAnonKey = getEnv('STUDYU_SUPABASE_PUBLIC_ANON_KEY');
final envAppUrl = getEnv('STUDYU_APP_URL');
final envDesignerUrl = getEnv('STUDYU_DESIGNER_URL');
final envProjectGeneratorUrl = getEnv('STUDYU_PROJECT_GENERATOR_URL');
await Supabase.initialize(
url: supabaseUrl,
anonKey: supabaseAnonKey,
url: supabaseUrl!,
anonKey: supabaseAnonKey!,
authCallbackUrlHostname: kIsWeb ? null : 'designer.studyu.health', // optional
debug: true,
// optional
Expand Down

0 comments on commit 55bfa31

Please sign in to comment.