Week 3 focuses on integrating Firebase services such as Authentication, Firestore, and Firebase Storage. It also involves ensuring the application can effectively manage changes in internet connectivity, providing feedback to users.
- Implement Firebase functionalities including Authentication, Firestore, and Firebase Storage.
- Handle internet connectivity changes and provide feedback to users.
- Develop user-friendly interfaces for product management and checkout processes.
Setting up Firebase for your Flutter project involves several critical steps. Here, we'll walk you through creating a new Firebase project, registering your app with Firebase, and configuring your Flutter app to use Firebase.
-
Open Firebase Console:
- Navigate to Firebase Console.
- You may need to log in with your Google account.
-
Add a New Project:
- Click on the "Add project" button.
- Enter your project name and follow the on-screen instructions.
- Select or create a Google Analytics account if required (optional but recommended for analytics).
-
Add Your App to the Firebase Project:
- Inside the Firebase project dashboard, click on the Web icon to add a new web app, or select the Android or iOS icon to add a mobile app, depending on your project needs.
- For an Android app, enter your app’s package name which you can find in your Flutter project’s
AndroidManifest.xml
file underpackage="com.example.yourapp"
. - Follow the prompts to name your app and register it.
-
Download Configuration File:
- For Android, download the
google-services.json
file. - For iOS, download the
GoogleService-Info.plist
file.
- For Android, download the
-
Place the Configuration File:
- For Android:
- Place the
google-services.json
file in your Flutter project underandroid/app/src/main/
.
- Place the
- For iOS:
- Place the
GoogleService-Info.plist
in theios/Runner
folder of your Flutter project.
- Place the
- For Android:
-
Update Your Project Settings:
- For Android, ensure that the Google services plugin is applied in your Gradle build script:
- Add
classpath 'com.google.gms:google-services:4.3.10'
(check for latest version) to your project levelbuild.gradle
file underdependencies
. - Add
apply plugin: 'com.google.gms.google-services'
at the bottom of the app-levelbuild.gradle
file.
- Add
- For Android, ensure that the Google services plugin is applied in your Gradle build script:
-
Sync Project with Gradle Files:
- Open your Flutter project and perform a Gradle sync in Android Studio or IntelliJ to ensure all dependencies are correctly configured.
-
Run Flutter Packages Get:
- Run
flutter packages get
in your terminal or use your IDE to sync all Dart packages.
- Run
- Run Your Application:
- Run your Flutter application to ensure that it initializes Firebase correctly on startup. Look for any logs in the console that confirm Firebase has been initialized successfully.
Objective: Ensure the application gracefully handles changes in internet connectivity, providing feedback to users.
-
Add the
connectivity_plus
package:dependencies: connectivity_plus: ^2.0.2
-
Implement connectivity status monitoring:
- Use the package to monitor connectivity changes.
- Implement logic to handle connectivity state changes and update the UI accordingly
-
Provide user feedback:
- Use visual indicators or messages to inform users when the internet connection is lost or re-established.
Objective: Securely authenticate users using Firebase Authentication.
-
Set up Firebase Authentication:
- Configure Firebase in your Flutter project.
- Enable email and google-login authentication methods.
-
Add Options for both email and google-login methods:
- refactor UI to give option for google-login
-
Integrate Firebase Authentication:
- Refactor existing authentication logic to use Firebase Authentication for Admins and Users.
Objective: Utilize Firebase Firestore for efficient data management.
-
Configure Firestore:
- Integrate Firestore into your Flutter project.
- Set up connection settings.
-
Design database schema:
- Define collections for customers, admins, products, and transactions.
- Ensure transaction documents include product details, payment ID, and invoice URL(if any).
-
Design Database models in flutter
- Add models for products,users and admins in Dart for efficient data management in App
-
Implement CRUD operations:
- Develop functionalities for adding, retrieving, updating, and deleting data.
Objective: Manage file storage using Firebase Storage.
-
Set up Firebase Storage:
- Integrate Firebase Storage into your project.
-
Implement file upload and retrieval:
- Create functionalities to upload and retrieve files, specifically for product images and invoices.
Objective: Develop interfaces for managing products and processing transactions.
-
Product addition page for admins:
- Allow admins to add product information by scanning barcodes and entering details manually in this page.
-
Develop checkout page UI:
- Fetch product data from firestore using barcode number.In case Product is not present,add new product using Prodcut addition page.
- Design and implement a checkout interface that updates in real-time as products are scanned.