Overview
Trackmart uses Firebase as its backend infrastructure for authentication, real-time data synchronization, and cloud storage. This guide will walk you through setting up all necessary Firebase services.Ensure you have a Firebase account and have created a project in the Firebase Console.
Firebase Services Used
Trackmart integrates the following Firebase services:Firebase Authentication
Phone and email authentication for users and drivers
Realtime Database
Real-time location tracking and order status updates
Cloud Firestore
User profiles, chat messages, and structured data storage
Cloud Storage
Profile photos and image uploads
Dependencies
The following Firebase packages are used in Trackmart:pubspec.yaml
Step 1: Create Firebase Project
Create a new project
Go to the Firebase Console and click “Add project”. Name your project “Trackmart” or your preferred name.
Enable Google Analytics (Optional)
Choose whether to enable Google Analytics for your project. This is recommended for tracking app usage.
Step 2: Configure Android App
Register Android app
In your Firebase project, click on the Android icon to add an Android app.
- Package name:
com.example.sandtrack(or your custom package name) - App nickname: Trackmart Android
- Debug signing certificate SHA-1: Optional for development
Download google-services.json
Download the
google-services.json file and place it in your Android app folder:Step 3: Configure iOS App
Register iOS app
In your Firebase project, click on the iOS icon to add an iOS app.
- Bundle ID: Match the bundle identifier in your
ios/Runner.xcodeproj - App nickname: Trackmart iOS
Download GoogleService-Info.plist
Download the
GoogleService-Info.plist file and add it to your Xcode project:- Open
ios/Runner.xcworkspacein Xcode - Drag
GoogleService-Info.plistinto the Runner folder - Ensure “Copy items if needed” is checked
Step 4: Enable Firebase Authentication
Enable Phone Authentication
- Enable the Phone sign-in provider
- No additional configuration required for development
- For production, you may need to add SHA-1 certificate fingerprints
Authentication Implementation
Trackmart implements dual authentication methods:- Phone Authentication
- Email Authentication
lib/login_page.dart
Step 5: Configure Realtime Database
Database Structure
Trackmart uses the following Realtime Database structure:View Database Schema
View Database Schema
Realtime Database is used for location tracking and order status updates that require real-time synchronization.
Step 6: Configure Cloud Firestore
Firestore Collections
Trackmart uses Firestore for structured data:- users: User profiles and metadata
- buyers: Buyer-specific information
- drivers: Driver profiles and availability
- messages: Chat messages between users and drivers
Step 7: Configure Cloud Storage
Step 8: Enable Persistence
Trackmart enables offline persistence for better performance:Verification
To verify your Firebase setup:Troubleshooting
MultidexEnabled Error
MultidexEnabled Error
If you see dex-related errors, ensure
multiDexEnabled true is set in android/app/build.gradle:Phone Authentication Not Working
Phone Authentication Not Working
- Verify SHA-1 fingerprint is added in Firebase Console (Android)
- Check that phone authentication is enabled in Firebase Console
- For iOS, ensure reverse client ID is added to Info.plist
Permission Denied Errors
Permission Denied Errors
Review your Realtime Database and Firestore security rules. For development, you can temporarily use:
Next Steps
Mapbox Integration
Configure Mapbox for real-time location tracking and routing
Push Notifications
Set up Firebase Cloud Messaging for order updates