-
-
Notifications
You must be signed in to change notification settings - Fork 53
Improve initialization and environment variable handling #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,67 +9,101 @@ import 'package:patient/presentation/widgets/snackbar_service.dart'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/provider/appointments_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/provider/assessment_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/provider/auth_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/repository/supabase_auth_repository.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/provider/reports_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/provider/task_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/provider/therapy_goals_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/repository/supabase_auth_repository.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:patient/repository/supabase_patient_repository.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:provider/provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'package:supabase_flutter/supabase_flutter.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Future<void> main() async { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WidgetsFlutterBinding.ensureInitialized(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'provider/task_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import 'provider/therapy_goals_provider.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Load environment variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await dotenv.load(fileName: ".env"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final supabaseUrl = dotenv.env['SUPABASE_URL']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final supabaseKey = dotenv.env['SUPABASE_ANON_KEY']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final geminiKey = dotenv.env['GEMINI_API_KEY']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Validate env variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (supabaseUrl == null || supabaseKey == null || geminiKey == null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw Exception("Missing environment variables in .env file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Future<void> main() async { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WidgetsFlutterBinding.ensureInitialized(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await dotenv.load(fileName: ".env"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await Supabase.initialize( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: dotenv.env['SUPABASE_URL']!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| anonKey: dotenv.env['SUPABASE_ANON_KEY']!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gemini.init(apiKey: dotenv.env['GEMINI_API_KEY']!); // Add your Gemini API key here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SystemChrome.setSystemUIOverlayStyle( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const SystemUiOverlayStyle( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| statusBarColor: Colors.white, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| statusBarIconBrightness: Brightness.dark, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemNavigationBarColor: Colors.white, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemNavigationBarIconBrightness: Brightness.dark, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setupDependencyInjection(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runApp( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MultiProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providers: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider(create: (_) => AssessmentProvider()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create: (_) => AuthProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authRepository: SupabaseAuthRepository( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| supabaseClient: Supabase.instance.client, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Initialize Supabase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await Supabase.initialize( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: supabaseUrl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| anonKey: supabaseKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Initialize Gemini | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gemini.init(apiKey: geminiKey); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // System UI styling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SystemChrome.setSystemUIOverlayStyle( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const SystemUiOverlayStyle( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| statusBarColor: Colors.white, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| statusBarIconBrightness: Brightness.dark, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemNavigationBarColor: Colors.white, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemNavigationBarIconBrightness: Brightness.dark, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Setup dependency injection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setupDependencyInjection(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Create shared repositories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final supabaseClient = Supabase.instance.client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final patientRepository = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SupabasePatientRepository(supabaseClient: supabaseClient); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final authRepository = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SupabaseAuthRepository(supabaseClient: supabaseClient); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runApp( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MultiProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providers: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider(create: (_) => AssessmentProvider()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create: (_) => AuthProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authRepository: authRepository, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider(create: (_) => ReportsProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: SupabasePatientRepository(supabaseClient: Supabase.instance.client), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider(create: (_) => TaskProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: SupabasePatientRepository(supabaseClient: Supabase.instance.client), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider(create: (_) => TherapyGoalsProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: SupabasePatientRepository(supabaseClient: Supabase.instance.client), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider(create: (_) => AppointmentsProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authRepository: SupabaseAuthRepository(supabaseClient: Supabase.instance.client), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: SupabasePatientRepository(supabaseClient: Supabase.instance.client) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child: const MyApp(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create: (_) => ReportsProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: patientRepository, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create: (_) => TaskProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: patientRepository, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create: (_) => TherapyGoalsProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: patientRepository, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChangeNotifierProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create: (_) => AppointmentsProvider( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authRepository: authRepository, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| patientRepository: patientRepository, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child: const MyApp(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugPrint("App initialization failed: $e"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+104
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. App fails silently if initialization errors occur - no UI is shown. If any initialization step throws (e.g., missing The PR objective was to "prevent crashes caused by missing .env variables," but this implementation still leaves the app in an unusable state. 🐛 Proposed fix: Show an error screen to the user } catch (e) {
debugPrint("App initialization failed: $e");
+ runApp(
+ MaterialApp(
+ home: Scaffold(
+ body: Center(
+ child: Padding(
+ padding: const EdgeInsets.all(24.0),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ const Icon(Icons.error_outline, size: 64, color: Colors.red),
+ const SizedBox(height: 16),
+ const Text(
+ 'Initialization Failed',
+ style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
+ ),
+ const SizedBox(height: 8),
+ Text(
+ e.toString(),
+ textAlign: TextAlign.center,
+ style: const TextStyle(color: Colors.grey),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class MyApp extends StatelessWidget { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -78,10 +112,14 @@ class MyApp extends StatelessWidget { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Widget build(BuildContext context) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return MaterialApp( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| scaffoldMessengerKey: SnackbarService.scaffoldMessengerKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugShowCheckedModeBanner: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: 'Patient App', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| theme: AppTheme.lightTheme(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| home: const SplashScreen()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| scaffoldMessengerKey: SnackbarService.scaffoldMessengerKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugShowCheckedModeBanner: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: 'NeuroTrack Patient', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| theme: AppTheme.lightTheme(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| initialRoute: '/', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| routes: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '/': (context) => const SplashScreen(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AOSSIE-Org/NeuroTrack
Length of output: 340
🏁 Script executed:
Repository: AOSSIE-Org/NeuroTrack
Length of output: 208
🏁 Script executed:
Repository: AOSSIE-Org/NeuroTrack
Length of output: 88
🏁 Script executed:
Repository: AOSSIE-Org/NeuroTrack
Length of output: 47
🏁 Script executed:
# Read the dependency injector to see what gets registered cat -n patient/lib/core/utils/dependency_injector.dartRepository: AOSSIE-Org/NeuroTrack
Length of output: 597
🏁 Script executed:
Repository: AOSSIE-Org/NeuroTrack
Length of output: 4065
Redundant repository instantiation creates inconsistent dependency management across the codebase.
setupDependencyInjection()registersSupabasePatientRepositoryas a singleton in GetIt, but lines 59-63 create new instances that are passed to providers. This results in:SupabasePatientRepositoryinstances in memorychat_manager.dartusesgetIt<PatientRepository>(), retrieving a different instanceUpdate
setupDependencyInjection()to also registerAuthRepository, then retrieve both repositories from GetIt instead of creating them manually:// Setup dependency injection setupDependencyInjection(); - // Create shared repositories - final supabaseClient = Supabase.instance.client; - final patientRepository = - SupabasePatientRepository(supabaseClient: supabaseClient); - final authRepository = - SupabaseAuthRepository(supabaseClient: supabaseClient); + // Retrieve shared repositories from GetIt + final patientRepository = getIt<PatientRepository>(); + final authRepository = getIt<AuthRepository>();This requires updating
setupDependencyInjection()independency_injector.dartto registerAuthRepository.🤖 Prompt for AI Agents