A new Flutter project.
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
-
Create flutter project:
- Visual Studio Code
- F1 -> Flutter: create project
- Clean project: flutter clean
- Run code (terminal): flutter run
-
Create a Github Repository:
- Create repository
- Init git in terminal
-
Add google services plugin:
- android/app/build.gradle: apply plugin: 'com.google.gms.google-services'
- android/build.gradle: classpath 'com.google.gms:google-services:4.3.5'
-
Setup Firebase for Flutter project:
- Create Firebase project
- Add Firebase to Flutter Project
- Firebase: with Flutter option
- Add firebase-core
- Add firebase-auth
- Add 'await Firebase.initializeApp();' in main.dart
- Enable Email/Password option in Firebase/Authentication
- Add an firebase instance (see commit "Email & Password - Firebase Authentication")
-
Do something after a 'try...catch...', have to bring it into 'try <>' and 'catch <>'. Not after 'try...catch...'
-
Login & signup with Google
- Get SHA-1 key (1): Open terminal in /android/gradlew and run ./gradlew signingReport and copy the SHA-1 key
- Get SHA-1 key (2):
- Open cmdline in jdk bin: C:\Program Files\Java\jdk-21.0.1\bin
- Find keystore: C:\Users\Admin.android\debug.keystore
- Replace keystore in keytool cmd and run: keytool -list -v -keystore C:\Users\Admin.android\debug.keystore -alias androiddebugkey
- Enter keyword: android
- Get SHA-1 key
- Other ways to get SHA-1 key: link 1 or link 2
- Fix error JAVA_HOME is not set
- Add GG sign-in package
- Add service/auth_service.dart: contain GG sign-in method
- Add GG sign-in method to Sign Up Page
-
Login with Facebook:
-
Keep the user log in:
- Uninstall the old version of app (login without logout causes issues)
- Add flutter_secure_storageflutter_secure_storage to store the access token and user data. Make sure that the minimum sdk version is 18 (config in android/app/build.gradle)
- Create AuthClass, which contains all method to signup, signin, logout and store access token
- Store the access token in AuthClass after sign in successfully
- Check if token is null or not to decide which page should be show first (main.dart)
-
Log out:
- Add a log out icon in the navbar of homepage to test log out function
- Create a log out method in AuthClass
- Set up:
- Add cloud firestore
- Add an entity: