feat(01-01): Create secure Supabase configuration system
- 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
This commit is contained in:
25
lib/core/constants/supabase_constants.dart
Normal file
25
lib/core/constants/supabase_constants.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
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',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user