- Created .env template with SUPABASE_URL and SUPABASE_ANON_KEY placeholders - Added .env to .gitignore to prevent committing secrets - Created SupabaseConstants class with secure environment loading - Added validation to ensure required environment variables are set - Created core/constants directory structure
25 lines
805 B
Dart
25 lines
805 B
Dart
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
|
|
/// Supabase configuration constants
|
|
/// Environment variables are loaded securely from .env file
|
|
class SupabaseConstants {
|
|
SupabaseConstants._();
|
|
|
|
static late final String supabaseUrl;
|
|
static late final String supabaseAnonKey;
|
|
|
|
/// Initialize Supabase constants from environment variables
|
|
static Future<void> initialize() async {
|
|
await dotenv.load(fileName: '.env');
|
|
|
|
supabaseUrl = dotenv.env['SUPABASE_URL'] ?? '';
|
|
supabaseAnonKey = dotenv.env['SUPABASE_ANON_KEY'] ?? '';
|
|
|
|
if (supabaseUrl.isEmpty || supabaseAnonKey.isEmpty) {
|
|
throw Exception(
|
|
'SUPABASE_URL and SUPABASE_ANON_KEY must be set in .env file\n'
|
|
'Get these values from Supabase Dashboard → Settings → API',
|
|
);
|
|
}
|
|
}
|
|
} |