From d385949053c1811c77ca205f763852cc44461bb4 Mon Sep 17 00:00:00 2001 From: Swetanshu <39398681+Swetanshu575@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:41:16 +0530 Subject: [PATCH 1/5] Update .env.example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File is uptodated with google Web client alues match what’s in your Supabase Dashboard (Project Settings > API) and Google Cloud Console (APIs & Services > Credentials). In the Supabase Dashboard, go to Authentication > Providers, ensure Google is enabled, and confirm the Client ID and Secret are correct. Check the redirect URI in Google Cloud Console. It should be https://your-project-id.supabase.co/auth/v1/callback. --- supabase/scripts/.env.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/supabase/scripts/.env.example b/supabase/scripts/.env.example index beb8642..b7ab496 100644 --- a/supabase/scripts/.env.example +++ b/supabase/scripts/.env.example @@ -1,3 +1,4 @@ SUPABASE_URL="your-supabase-url" SUPABASE_KEY="your-supabase-key" - +GOOGLE_WEB_CLIENT_ID="your_web_client_id" +GOOGLE_SECRET_KEY="your_secret_key" From 5b1a218f9bcbcfaf2c33e0267707fe84b6dfc940 Mon Sep 17 00:00:00 2001 From: Swetanshu <39398681+Swetanshu575@users.noreply.github.com> Date: Mon, 7 Apr 2025 22:26:42 +0530 Subject: [PATCH 2/5] Update main.dart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The specific issue we discussed earlier was a Widget Build Error related to ScaffoldMessenger.of(context) not finding a ScaffoldMessenger widget in the widget tree, often because the context used doesn’t have a Scaffold ancestor. In the code you shared, I notice the following: Use of ScaffoldMessengerKey In the MyApp widget, you’re using a GlobalKey for the ScaffoldMessenger: dart return MaterialApp( scaffoldMessengerKey: SnackbarService.scaffoldMessengerKey, debugShowCheckedModeBanner: false, title: 'Patient App', theme: AppTheme.lightTheme(), home: const SplashScreen()); This is a good approach! By using a GlobalKey (likely defined in snackbar_service.dart), you can show SnackBars anywhere in the app without worrying about the context. --- patient/lib/main.dart | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/patient/lib/main.dart b/patient/lib/main.dart index 1947c67..5306e3f 100644 --- a/patient/lib/main.dart +++ b/patient/lib/main.dart @@ -8,21 +8,11 @@ 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:provider/provider.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; - - -import 'core/theme/theme.dart'; -import 'presentation/splash_screen.dart'; -import 'provider/assessment_provider.dart'; - -import 'provider/task_provider.dart'; - - Future main() async { WidgetsFlutterBinding.ensureInitialized(); await dotenv.load(fileName: ".env"); @@ -73,3 +63,9 @@ class MyApp extends StatelessWidget { home: const SplashScreen()); } } +'''a Widget Build Error related to ScaffoldMessenger.of(context) not finding a ScaffoldMessenger widget in the widget tree, often because the context used doesn’t have a Scaffold ancestor. In the code you shared, I notice the following: +Use of ScaffoldMessengerKey +In the MyApp widget, you’re using a GlobalKey for the ScaffoldMessenger: +dart + +''' From 145955021d57a1309b8e56d5c32e9d9bd95bc10d Mon Sep 17 00:00:00 2001 From: Swetanshu <39398681+Swetanshu575@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:34:45 +0530 Subject: [PATCH 3/5] adding missing files --- patient/lib/onboarding_screen.dart | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 patient/lib/onboarding_screen.dart diff --git a/patient/lib/onboarding_screen.dart b/patient/lib/onboarding_screen.dart new file mode 100644 index 0000000..7b083b8 --- /dev/null +++ b/patient/lib/onboarding_screen.dart @@ -0,0 +1,43 @@ +class SplashScreen extends StatefulWidget { + const SplashScreen({super.key}); + + @override + _SplashScreenState createState() => _SplashScreenState(); +} + +class _SplashScreenState extends State { + @override + void initState() { + super.initState(); + _checkUserStatus(); + } + + Future _checkUserStatus() async { + final authProvider = Provider.of(context, listen: false); + await Future.delayed(const Duration(seconds: 2)); // Simulate splash delay + if (authProvider.isAuthenticated) { + final profile = await Supabase.instance.client + .from('profiles') + .select() + .eq('user_id', authProvider.user!.id) + .maybeSingle(); + if (profile == null) { + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (_) => const OnboardingScreen()), + ); + } else { + Navigator.pushReplacementNamed(context, '/home'); + } + } else { + Navigator.pushReplacementNamed(context, '/login'); + } + } + + @override + Widget build(BuildContext context) { + return const Scaffold( + body: Center(child: Text('NeuroTrack')), + ); + } +} \ No newline at end of file From 283c7c70910ed417dddc5cbb01be92282c395d27 Mon Sep 17 00:00:00 2001 From: Swetanshu <39398681+Swetanshu575@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:35:17 +0530 Subject: [PATCH 4/5] Update main.dart --- patient/lib/main.dart | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/patient/lib/main.dart b/patient/lib/main.dart index 5306e3f..27d708d 100644 --- a/patient/lib/main.dart +++ b/patient/lib/main.dart @@ -15,12 +15,24 @@ import 'package:supabase_flutter/supabase_flutter.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); + + // Load environment variables from .env file await dotenv.load(fileName: ".env"); + + // Validate that Supabase credentials are present + final supabaseUrl = dotenv.env['SUPABASE_URL']; + final supabaseAnonKey = dotenv.env['SUPABASE_ANON_KEY']; + if (supabaseUrl == null || supabaseAnonKey == null) { + throw Exception('Supabase URL or Anon Key missing in .env file'); + } + + // Initialize Supabase await Supabase.initialize( - url: dotenv.env['SUPABASE_URL']!, - anonKey: dotenv.env['SUPABASE_ANON_KEY']!, + url: supabaseUrl, + anonKey: supabaseAnonKey, ); + // Set system UI overlay style SystemChrome.setSystemUIOverlayStyle( const SystemUiOverlayStyle( statusBarColor: Colors.white, @@ -43,7 +55,7 @@ Future main() async { ), ChangeNotifierProvider(create: (_) => ReportsProvider()), ChangeNotifierProvider(create: (_) => TaskProvider()), - ChangeNotifierProvider(create: (_) => AppointmentsProvider()) + ChangeNotifierProvider(create: (_) => AppointmentsProvider()), ], child: const MyApp(), ), @@ -56,16 +68,16 @@ 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, // Global key for SnackBar + debugShowCheckedModeBanner: false, + title: 'Patient App', + theme: AppTheme.lightTheme(), + home: const SplashScreen(), + // Define named routes if needed (e.g., for navigation after onboarding) + routes: { + '/home': (context) => const Placeholder(), // Replace with actual home screen + '/login': (context) => const Placeholder(), // Replace with actual login screen + }, + ); } } -'''a Widget Build Error related to ScaffoldMessenger.of(context) not finding a ScaffoldMessenger widget in the widget tree, often because the context used doesn’t have a Scaffold ancestor. In the code you shared, I notice the following: -Use of ScaffoldMessengerKey -In the MyApp widget, you’re using a GlobalKey for the ScaffoldMessenger: -dart - -''' From e46c739b8418ffcde1a8ce3aa2e6f10bca4e662f Mon Sep 17 00:00:00 2001 From: Swetanshu <39398681+Swetanshu575@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:35:53 +0530 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0d43731..ce7e291 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,10 @@ Replace placeholders with actual values from **Supabase** and **Google Cloud Con - Professional certifications - Background verification - Admin approval process before full platform access +### Troubleshooting +- **Flutter run fails with "Supabase not initialized"**: Ensure `.env` file exists in `patient/` and `therapist/` with correct `SUPABASE_URL` and `SUPABASE_ANON_KEY`. +- **Google OAuth redirect fails**: Double-check the redirect URI in Google Cloud Console matches `https://your-project-id.supabase.co/auth/v1/callback`. +- **Dependencies not found**: Run `flutter pub get` in both `patient/` and `therapist/` directories. ### Patient Management