diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..ad32100
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "java.configuration.updateBuildConfiguration": "interactive",
+ "cmake.sourceDirectory": "C:/Users/akd24/Documents/GetWelPlus/flutter_app/linux"
+}
\ No newline at end of file
diff --git a/flutter_app/android/app/build.gradle.kts b/flutter_app/android/app/build.gradle.kts
index 343f129..7da92e3 100644
--- a/flutter_app/android/app/build.gradle.kts
+++ b/flutter_app/android/app/build.gradle.kts
@@ -1,10 +1,7 @@
plugins {
id("com.android.application")
id("kotlin-android")
- // Add the Google services Gradle plugin
- id("com.google.gms.google-services")
- // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
@@ -27,10 +24,11 @@ android {
applicationId = "com.example.flutter_app"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
- minSdk = flutter.minSdkVersion
+ minSdk = flutter.minSdkVersion // Required for Supabase
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
+ multiDexEnabled = true // Required for apps with many dependencies
}
buildTypes {
@@ -47,15 +45,6 @@ flutter {
}
dependencies {
- // Import the Firebase BoM
- implementation(platform("com.google.firebase:firebase-bom:34.8.0"))
-
-
- // TODO: Add the dependencies for Firebase products you want to use
- // When using the BoM, don't specify versions in Firebase dependencies
- implementation("com.google.firebase:firebase-analytics")
-
-
- // Add the dependencies for any other desired Firebase products
- // https://firebase.google.com/docs/android/setup#available-libraries
+ implementation("com.google.android.gms:play-services-auth:21.1.0")
+ implementation("androidx.multidex:multidex:2.0.1")
}
diff --git a/flutter_app/android/app/src/main/AndroidManifest.xml b/flutter_app/android/app/src/main/AndroidManifest.xml
index 3eac92d..26ac042 100644
--- a/flutter_app/android/app/src/main/AndroidManifest.xml
+++ b/flutter_app/android/app/src/main/AndroidManifest.xml
@@ -1,4 +1,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -41,5 +55,13 @@
+
+
+
+
+
+
+
+
diff --git a/flutter_app/android/app/src/main/res/xml/network_security_config.xml b/flutter_app/android/app/src/main/res/xml/network_security_config.xml
new file mode 100644
index 0000000..c1484a2
--- /dev/null
+++ b/flutter_app/android/app/src/main/res/xml/network_security_config.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+ supabase.co
+
+
+
+
+
+
diff --git a/flutter_app/android/build.gradle.kts b/flutter_app/android/build.gradle.kts
index de12210..7687ef6 100644
--- a/flutter_app/android/build.gradle.kts
+++ b/flutter_app/android/build.gradle.kts
@@ -1,9 +1,5 @@
plugins {
// ...
-
- // Add the dependency for the Google services Gradle plugin
- id("com.google.gms.google-services") version "4.4.4" apply false
-
}
allprojects {
repositories {
diff --git a/flutter_app/lib/auth/auth_provider.dart b/flutter_app/lib/auth/auth_provider.dart
index f405280..d542765 100644
--- a/flutter_app/lib/auth/auth_provider.dart
+++ b/flutter_app/lib/auth/auth_provider.dart
@@ -1,13 +1,18 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:firebase_auth/firebase_auth.dart';
+import 'package:supabase_flutter/supabase_flutter.dart';
import 'auth_service.dart';
-// Give app access to AuthService
+// Provide access to AuthService
final authServiceProvider = Provider((ref) {
return AuthService();
});
-// Listen to Firebase auth state
-final authStateProvider = StreamProvider((ref) {
- return ref.read(authServiceProvider).authstatechanges;
-});
\ No newline at end of file
+// Listen to Supabase auth state changes
+final authStateProvider = StreamProvider((ref) {
+ return ref.read(authServiceProvider).authStateChanges;
+});
+
+// Get current user
+final currentUserProvider = Provider((ref) {
+ return ref.read(authServiceProvider).currentUser;
+});
diff --git a/flutter_app/lib/auth/auth_service.dart b/flutter_app/lib/auth/auth_service.dart
index 91c7505..adfdb13 100644
--- a/flutter_app/lib/auth/auth_service.dart
+++ b/flutter_app/lib/auth/auth_service.dart
@@ -1,32 +1,160 @@
-import 'package:firebase_auth/firebase_auth.dart';
+import 'package:supabase_flutter/supabase_flutter.dart';
+import 'package:google_sign_in/google_sign_in.dart';
+class AuthService {
+ final SupabaseClient _supabase = Supabase.instance.client;
+ // Get current user
+ User? get currentUser => _supabase.auth.currentUser;
-class AuthService {
+ // Listen to auth state changes
+ Stream get authStateChanges => _supabase.auth.onAuthStateChange;
+
+ // Check if user is logged in
+ bool get isLoggedIn => currentUser != null;
- final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
- User? get currentuser => firebaseAuth.currentUser;
+ // Sign up with email and password
+ Future signUp({
+ required String email,
+ required String password,
+ required String name,
+ }) async {
+ try {
+ final response = await _supabase.auth.signUp(
+ email: email,
+ password: password,
+ data: {'name': name},
+ );
- Stream get authstatechanges => firebaseAuth.authStateChanges();
+ if (response.user != null) {
+ try {
+ await _supabase.from('users').insert({
+ 'id': response.user!.id,
+ 'email': email,
+ 'name': name,
+ 'created_at': DateTime.now().toIso8601String(),
+ });
+ } catch (dbError) {
+ // User already created in auth, profile creation can be retried later
+ }
+ }
- Future login({
+ return response;
+ } catch (e) {
+ rethrow;
+ }
+ }
+
+ // Sign in with email and password
+ Future signIn({
required String email,
required String password,
+ }) async {
+ try {
+ return await _supabase.auth.signInWithPassword(
+ email: email,
+ password: password,
+ );
+ } catch (e) {
+ rethrow;
+ }
+ }
+
+ // Sign in with Google
+ Future signInWithGoogle() async {
+ try {
+ const webClientId =
+ '632491342639-mq70dmjhr8udmps5t312gkcrc5d90a17.apps.googleusercontent.com';
- }) async{
- return await firebaseAuth.signInWithEmailAndPassword(email: email, password: password);
+ final GoogleSignIn googleSignIn = GoogleSignIn(
+ serverClientId: webClientId,
+ scopes: ['email', 'profile'],
+ );
+
+ final googleUser = await googleSignIn.signIn();
+ if (googleUser == null) {
+ return false;
+ }
+
+ final googleAuth = await googleUser.authentication;
+ final accessToken = googleAuth.accessToken;
+ final idToken = googleAuth.idToken;
+
+ if (accessToken == null || idToken == null) {
+ throw 'Google authentication tokens not found';
+ }
+
+ final response = await _supabase.auth.signInWithIdToken(
+ provider: OAuthProvider.google,
+ idToken: idToken,
+ accessToken: accessToken,
+ );
+
+ // Create user profile if it doesn't exist
+ if (response.user != null) {
+ final existingUser = await _supabase
+ .from('users')
+ .select()
+ .eq('id', response.user!.id)
+ .maybeSingle();
+
+ if (existingUser == null) {
+ await _supabase.from('users').insert({
+ 'id': response.user!.id,
+ 'email': response.user!.email,
+ 'name': googleUser.displayName ?? 'User',
+ 'created_at': DateTime.now().toIso8601String(),
+ });
+ }
+ }
+
+ return true;
+ } catch (e) {
+ rethrow;
+ }
}
- Future signup({
- required String email,
- required String password,
- }) async{
- return await firebaseAuth.createUserWithEmailAndPassword(email: email, password: password);
+ // Sign out
+ Future signOut() async {
+ try {
+ await _supabase.auth.signOut();
+ } catch (e) {
+ rethrow;
+ }
}
- Future logout() async{
- await firebaseAuth.signOut();
+ // Get user profile from database
+ Future