Transit Post

Overview

The Transit Post Package is a Flutter module designed to streamline transit post operations, such as selecting posts, scanning resources, and tracking deliveries. Built for seamless integration in larger logistics and delivery systems, it leverages Bloc for robust state management and uses reactive forms for capturing user input efficiently. The module is structured for reusability, testability, and separation of concerns via repository patterns.


Key Features

User Interface (Pages)

The user interface is organised into modular pages, each responsible for a distinct step in the transit post workflow. These pages are designed to be simple, responsive, and directly integrated with Bloc state management for dynamic updates.

  • transit_post_selection.dart UI for displaying and selecting available transit posts. Initiates the delivery process and triggers navigation to the recording step.

  • transit_post_record_vaccination.dart UI for resource scanning (QR/barcode) and entry of delivery details using reactive forms. Performs validation and provides real-time feedback.

  • transit_post_acknowledgment.dart Displays a summary and acknowledgement after a successful delivery submission.

  • transit_post_wrapper.dart Acts as the parent widget, managing navigation and Bloc provisioning for the entire flow.

State Management (Bloc Pattern)

The application uses the Bloc pattern to ensure predictable state management, clear separation of concerns, and a responsive user interface throughout the transit post workflow. Each Bloc handles a specific stage of the process:

  • TransitPostSelectionBloc

    • Manages loading and selection of transit posts.

    • Events: LoadPosts, SelectPost

    • States: Loading, Loaded, Selected, Error

  • TransitPostRecordVaccinationBloc

    • Handles scanning, form input, and delivery validation.

    • Events: StartScan, SubmitDelivery, ValidateInput

    • States: Initial, Scanning, Validated, Delivered, Error

  • TransitPostAcknowledgmentBloc

    • Controls the acknowledgement and confirmation stage.

    • Events: Acknowledge, Reset

    • States: Pending, Acknowledged

  • Bloc Integration

    • Each page provides or consumes its relevant Bloc using BlocProvider or BlocConsumer.

    • UI reacts to state changes for navigation and updates.

Data Layer (Repositories)

The application follows the Repository pattern to keep business logic independent from data storage and networking, making the system modular, testable, and easy to extend. Two key repository abstractions are defined:

  • UserActionLocalRepository (abstract)

    • Handles local persistence (e.g., SQLite, Hive)

    • Methods: saveDelivery, getPendingDeliveries, markAsAcknowledged

  • UserActionRemoteRepository (abstract)

    • Handles remote persistence (API integration)

    • Methods: submitDelivery, fetchTransitPosts, fetchDeliveryHistory

Reactive Forms

The application uses the reactive_forms package to manage dynamic and validated data entry during the transit post flow. This approach ensures a structured way to capture delivery details while providing immediate feedback to users.

  • Dynamic Form Handling – Forms can adapt to different input types such as resource details, quantities, or delivery metadata, enabling flexible data capture for various scenarios.

  • Built-in Validation – Validation rules are applied directly within the form controls, ensuring data accuracy. Errors and invalid inputs are highlighted in real time, guiding the user to correct issues before submission.

  • Seamless UI Feedback – The form state is reactive, meaning any change in input instantly reflects in the UI. This creates a smooth user experience with live validation messages and input tracking.

By combining dynamic fields, validation, and real-time feedback, Reactive Forms make the delivery recording process reliable, user-friendly, and less prone to data entry errors.


Key Classes & Structure

  • UI Widgets:

    • TransitPostSelectionPage

    • TransitPostRecordVaccinationPage

    • TransitPostAcknowledgmentPage

    • TransitPostWrapper

  • Bloc Classes:

    • TransitPostSelectionBloc, TransitPostSelectionEvent, TransitPostSelectionState

    • TransitPostRecordVaccinationBloc, TransitPostRecordVaccinationEvent, TransitPostRecordVaccinationState

    • TransitPostAcknowledgmentBloc, TransitPostAcknowledgmentEvent, TransitPostAcknowledgmentState

  • Repositories (Abstract):

    • UserActionLocalRepository

    • UserActionRemoteRepository


Note: The modular design makes the Transit Post Package extensible for other resource types and business rules by adding new pages, events, or repository implementations.

Sequence Diagram

Last updated

Was this helpful?