Code Structure

Understanding the code structure of your Flutter project is essential for maintaining and scaling the application efficiently.
This document provides a concise, developer-friendly overview of the project’s architecture, folder hierarchy, and responsibilities — prepared for CodeCanyon submission.


Overview

  • Framework: Flutter (Dart)
  • State Management: Provider
  • Networking: Dio
  • Localization: easy_localization
  • Persistence: shared_preferences
  • Geo: geolocator, permission_handler

Project Structure

This project follows a clean architecture pattern, ensuring clear separation between UI, state management, data handling, and utilities.

lib/
├── configs/
├── core/
│   ├── common_widgets/
│   ├── constants/
│   ├── models/
│   ├── providers/
│   ├── services/
│   ├── utils/
│   └── widgets/
├── data/
│   ├── local/
│   ├── repositories/
│   └── service/
├── page/
│   ├── splash/
│   ├── auth/
│   ├── home/
│   ├── attendance/
│   ├── attendance_report/
│   ├── leave_request/
│   ├── employee_directory/
│   ├── notification/
│   ├── content_pages/
│   ├── profile/
│   ├── settings_screen/
│   └── welcome/
└── assets/

Key Files and Responsibilities

  • lib/configs/api_configs.dart: Base URL, endpoints, and request configuration.
  • lib/main.dart: App entry, localization, theme, routing, provider registration.
  • lib/core/providers/**/*.dart: Feature state and actions (auth, home, leave, notifications, etc.).
  • lib/data/repositories/**/*.dart: External API access; each feature has its repository.
  • lib/core/models/**/*.dart: Strongly typed request/response models per feature.
  • lib/core/services/auth_error_handler.dart: Central handler to intercept auth failures and redirect via navigatorKey.
  • lib/core/utils/validators.dart: Form and input validators used across the app.
  • lib/page/**: Feature-first UI structure. Each feature has view/ screens and widget/ components.

Localization

  • JSON files in assets/translations/ (en, ar, es, hi, zh). Initialized in main.dart via EasyLocalization.

Theming & Design System

  • Centralized in lib/core/constants/ to ensure consistent colors, typography, and spacing.

How Things Flow (Typical Example)

  1. UI in lib/page/.../view/*.dart triggers an action (e.g., check-in).
  2. The corresponding Provider (e.g., check_in_check_out provider) coordinates the call.
  3. Provider uses the appropriate Repository to call the backend via Dio.
  4. Responses are parsed into models under lib/core/models/** and update provider state.
  5. UI listens to provider changes and rebuilds using Flutter widgets from common_widgets/.

Dependencies (from pubspec.yaml)

  • The project depends on easy_localization, provider, dio, shared_preferences, geolocator, permission_handler, cached_network_image, shimmer, flutter_html, and others for UI and UX enhancements.