Skip to main content

Overview

Trackmart follows a standard Flutter project structure with organized directories for source code, assets, and platform-specific configurations. The application is built around a three-tab interface for chats, order requests, and order history.

Directory Structure

trackmart/
├── android/              # Android-specific configuration
├── ios/                  # iOS-specific configuration
├── lib/                  # Dart source code
├── assets/              # Images and other assets
│   ├── images/
│   └── launcher/
├── test/                # Unit and widget tests
├── test_driver/         # Integration tests
├── pubspec.yaml         # Project dependencies and metadata
└── README.md           # Project documentation

Source Code Structure (lib/)

The application source code is organized into modular Dart files, each responsible for specific features:

Core Files

Location: lib/main.dartThe entry point of the application that initializes the Flutter app with Material Design theming.Key Components:
  • MyApp widget: Root widget that sets up the app theme
  • Custom color scheme: Teal primary color (#004d40) and blue accent (#005B9A)
  • Routes to RootPage for authentication handling
Code Reference: lib/main.dart:6
Location: lib/root_page.dartManages authentication state and routing between login and home screens.Key Features:
  • Firebase authentication state management
  • Push notification configuration (Firebase Messaging)
  • Local notification setup
  • Email verification checks
  • Device token registration
Authentication States:
  • notSignedIn: Shows login page
  • signedIn: Shows home page
  • loading: Shows splash screen with truck icon
Code Reference: lib/root_page.dart:18-24
Location: lib/login_page.dartHandles user authentication flow including phone number and email verification.Features:
  • Phone number authentication with OTP
  • Email/password authentication
  • Country code picker integration
  • User profile creation
  • SharedPreferences for local data storage
Code Reference: lib/login_page.dart
Location: lib/home_page.dartThe main interface after login featuring a three-tab layout.Three Main Tabs:
  1. Chats Tab: List of drivers for messaging
  2. Request Tab: Order creation interface with quantity, unit, and payment selection
  3. Orders Tab: Order history categorized as Requested, In Transit, and Delivered
Key Functionality:
  • Real-time location tracking using Geolocator
  • Firebase Realtime Database and Firestore integration
  • Driver search and selection
  • Dynamic pricing with currency conversion
  • Order management (create, track, rate)
  • Local database (SQLite) for offline support
Code Reference: lib/home_page.dart:48-56

Feature Files

map.dart

Interactive map view using flutter_map
  • Display driver locations
  • User location marker
  • Route visualization
  • Driver selection from map

chat.dart

Real-time messaging with drivers
  • Firestore-based chat
  • Image sharing support
  • Message notifications
  • Typing indicators

settings.dart

User profile management
  • Profile photo upload
  • Display name editing
  • Account settings
  • Firebase Storage integration

support.dart

Help and support page
  • FAQs
  • Contact information
  • App guidance

contact.dart

Contact information page
  • Company details
  • Phone and email links
  • URL launcher integration

about.dart

About the application
  • App information
  • Version details
  • Credits

credit_card_page.dart

Payment interface (card payments)
  • Card input fields
  • Payment processing
  • BLoC pattern implementation

credit_card_bloc.dart

Business logic for card payments
  • Stream-based state management
  • Card validation
  • Payment processing logic

Utility Files

Location: lib/uidata.dartContains UI-related constants and data.Includes:
  • Color schemes
  • String constants
  • Static UI data
  • Asset paths
Location: lib/const.dartGlobal constants used throughout the application.Typical Contents:
  • API endpoints
  • Configuration values
  • Default settings
Location: lib/profile_tile.dartA reusable widget for displaying user profile information in a list tile format.

Platform-Specific Directories

Android Configuration

Directory: android/Contains Android-specific configuration files:
  • app/build.gradle: App-level Gradle configuration
  • build.gradle: Project-level Gradle configuration
  • app/src/main/AndroidManifest.xml: App permissions and metadata
  • app/google-services.json: Firebase configuration (not in version control)
Key Permissions Required:
  • Location access (fine and coarse)
  • Internet access
  • Camera (for profile photos)
  • Storage (for image caching)

iOS Configuration

Directory: ios/Contains iOS-specific configuration files:
  • Runner.xcworkspace: Xcode workspace
  • Runner/Info.plist: App configuration and permissions
  • Runner/GoogleService-Info.plist: Firebase configuration (not in version control)
  • Podfile: CocoaPods dependencies
Key Permissions Required:
  • Location (when in use and always)
  • Camera access
  • Photo library access
  • Notifications

Assets Directory

assets/
├── images/          # App images and icons
└── launcher/        # App launcher icons
    └── icon.png
Assets are declared in pubspec.yaml and must be registered before use:
flutter:
  assets:
    - assets/images/
    - assets/launcher/

Application Flow

1

App Launch

main.dart initializes the app and displays RootPage
2

Authentication Check

RootPage checks Firebase auth state:
  • If not signed in → Show LoginPage
  • If signed in → Show HomePage
  • While checking → Show loading screen
3

Login Flow

User authenticates via phone or email in LoginPage, then redirected to HomePage
4

Main Interface

HomePage displays three tabs:
  1. Chats with drivers
  2. Order request form
  3. Order history and tracking
5

Feature Navigation

Users can navigate to:
  • Map view (map.dart)
  • Chat interface (chat.dart)
  • Settings (settings.dart)
  • Support and About pages

State Management

The application uses multiple state management approaches:

StatefulWidget

Most screens use Flutter’s built-in StatefulWidget for local state management

BLoC Pattern

Credit card functionality uses BLoC (Business Logic Component) pattern for separation of concerns

Firebase Realtime

Real-time data updates from Firebase Database and Firestore using StreamBuilder

SharedPreferences

Local persistent storage for user preferences and cached data

Data Storage

Structure:
- Drivers/
  - [driverId]/
    - requests/
    - profile info
- buyers/
  - [userId]/
    - requests/
    - transit/
    - delivered/
    - profile info
Used for: Order requests, real-time location updates, driver-buyer relationships

Testing Structure

Unit Tests

Location: test/Test individual functions and classes in isolation

Integration Tests

Location: test_driver/Test complete user flows using flutter_gherkin for BDD-style testing

Next Steps

Installation Guide

Set up your development environment

Dependencies

Explore the packages and libraries used

Build docs developers (and LLMs) love