updated login

This commit is contained in:
Mike Kell 2025-07-28 20:28:24 -04:00
parent 00c5063723
commit 8ef25865f3
3 changed files with 35 additions and 16 deletions

View File

@ -0,0 +1,11 @@
// lib/config/env.dart
import 'package:flutter_dotenv/flutter_dotenv.dart';
class Env {
static Future<void> load() async {
await dotenv.load(); // loads .env from assets
}
static String get supabaseUrl => dotenv.get('SUPABASE_URL');
static String get supabaseAnon => dotenv.get('SUPABASE_ANON_KEY');
}

View File

@ -1,4 +1,6 @@
// lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
import 'screens/splash_screen.dart'; import 'screens/splash_screen.dart';
@ -6,17 +8,18 @@ import 'screens/splash_screen.dart';
Future<void> main() async { Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await Supabase.initialize( // Load variables from .env (added as asset in pubspec.yaml)
url: const String.fromEnvironment( await dotenv.load(fileName: '.env');
'SUPABASE_URL',
defaultValue: 'https://YOUR-SUPABASE-URL.supabase.co',
),
anonKey: const String.fromEnvironment(
'SUPABASE_ANON_KEY',
defaultValue: 'YOUR-SUPABASE-ANON-KEY',
),
);
final supabaseUrl = dotenv.env['SUPABASE_URL'];
final supabaseAnonKey = dotenv.env['SUPABASE_ANON_KEY'];
assert(supabaseUrl != null && supabaseAnonKey != null);
// Initialise Supabase with the values from .env
await Supabase.initialize(url: supabaseUrl!, anonKey: supabaseAnonKey!);
// Launch the app
runApp(const ComplyCoreApp()); runApp(const ComplyCoreApp());
} }
@ -24,9 +27,11 @@ class ComplyCoreApp extends StatelessWidget {
const ComplyCoreApp({super.key}); const ComplyCoreApp({super.key});
@override @override
Widget build(BuildContext context) => MaterialApp( Widget build(BuildContext context) {
return MaterialApp(
title: 'ComplyCore', title: 'ComplyCore',
theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: true), theme: ThemeData(useMaterial3: true, primarySwatch: Colors.blue),
home: const SplashScreen(), home: const SplashScreen(),
); );
}
} }

View File

@ -40,6 +40,7 @@ dependencies:
http: ^1.2.0 http: ^1.2.0
dart_jsonwebtoken: ^2.12.1 dart_jsonwebtoken: ^2.12.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
@ -57,12 +58,14 @@ dev_dependencies:
# The following section is specific to Flutter packages. # The following section is specific to Flutter packages.
flutter: flutter:
# The following line ensures that the Material Icons font is # The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in
# the material Icons class. # the material Icons class.
uses-material-design: true uses-material-design: true
# To add assets to your application, add an assets section, like this: assets:
- .env
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg