Skip to content

elrizwiraswara/flutter_pos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

250 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flutter POS

License: MIT Made with Flutter

πŸš€ This project is the base model of Zirel POS. If you want a ready-to-use, feature-complete POS app, you might want to check it out, it's free, no card required.

A Point of Sale (POS) application built with Flutter, demonstrating Clean Architecture principles and offline-first design patterns. This project serves as a learning resource and reference implementation for building Flutter apps with proper architecture and automatic data synchronization between local storage (SQLite) and cloud database (Firestore).

The app prioritizes local-first operations, storing all data in SQLite and automatically syncing with Firestore when online. When offline, all user actions (create, update, delete) are recorded as QueuedActions in the local database and automatically executed in sequence when internet connectivity is restored.


Image 2 Image 1 Image 2 Image 2 Image 2

Demo APK

Download Demo APK

Features

Core Functionality

  • Product Management: Full CRUD operations for products with image upload support
  • Sales Transactions: POS interface with cart management and transaction history
  • Thermal Receipt Printing: Print transaction receipts via USB, Bluetooth, BLE, or network printers with configurable paper sizes (58mm, 72mm, 80mm)
  • User Authentication: Firebase Authentication with Google Sign-In integration
  • Account Management: User profile management and settings

Technical Implementation

  • Offline-First Architecture: Works seamlessly without internet connection
  • Automatic Data Sync: SQLite ↔ Firestore bidirectional synchronization
  • Queued Actions: Automatic retry mechanism for offline operations (create, update, delete)
  • Clean Architecture: Separation between presentation, domain, and data layers
  • State Management: Riverpod (migrated from Provider) for safer, more testable state management
  • Dependency Injection: Centralized DI setup for better code organization
  • Unit Testing: Tests for datasources, repositories, and use cases
  • Material Design 3: Material design 3 and Dark & Light theme switching support
  • Customizable Theming: Adjustable colors and typography
  • Multi-Platform: Supports Android, iOS, Windows, macOS, and Linux
  • Error Handling: User-friendly error messages and states
  • Reusable Widgets: Custom UI components for consistent design

Architecture

Architecture

Project Structure

flutter_pos/
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ app/                          # Application setup and configuration
β”‚   β”‚   β”œβ”€β”€ di/                       # Dependency injection
β”‚   β”‚   β”œβ”€β”€ error/                    # Error handling
β”‚   β”‚   └── routes/                   # App routing and navigation
β”‚   β”‚
β”‚   β”œβ”€β”€ core/                         # Core utilities and shared resources
β”‚   β”‚   β”œβ”€β”€ assets/                   # Asset management
β”‚   β”‚   β”œβ”€β”€ common/                   # Common utilities (Result wrapper)
β”‚   β”‚   β”œβ”€β”€ constants/                # App constants
β”‚   β”‚   β”œβ”€β”€ extensions/               # Dart extensions
β”‚   β”‚   β”œβ”€β”€ locale/                   # Localization
β”‚   β”‚   β”œβ”€β”€ services/                 # Core services
β”‚   β”‚   β”‚   β”œβ”€β”€ connectivity/         # Network connectivity checking
β”‚   β”‚   β”‚   β”œβ”€β”€ database/             # Local database service (sqflite)
β”‚   β”‚   β”‚   β”œβ”€β”€ info/                 # Device info service
β”‚   β”‚   β”‚   β”œβ”€β”€ logger/               # Error logging service
β”‚   β”‚   β”‚   └── printer/              # Thermal printer service
β”‚   β”‚   β”œβ”€β”€ themes/                   # App theming (colors, sizes, themes)
β”‚   β”‚   β”œβ”€β”€ usecase/                  # Base usecase interface
β”‚   β”‚   └── utilities/                # Helper utilities (formatters, loggers, etc.)
β”‚   β”‚
β”‚   β”œβ”€β”€ data/                         # Data layer
β”‚   β”‚   β”œβ”€β”€ datasources/              # Data sources
β”‚   β”‚   β”‚   β”œβ”€β”€ interfaces/           # Datasource interfaces
β”‚   β”‚   β”‚   β”œβ”€β”€ local/                # Local datasources (sqflite)
β”‚   β”‚   β”‚   └── remote/               # Remote datasources (Firestore, Firebase Auth)
β”‚   β”‚   β”œβ”€β”€ models/                   # Data models with JSON serialization
β”‚   β”‚   └── repositories/             # Repository implementations
β”‚   β”‚
β”‚   β”œβ”€β”€ domain/                       # Domain layer (Business logic)
β”‚   β”‚   β”œβ”€β”€ entities/                 # Business entities
β”‚   β”‚   β”œβ”€β”€ repositories/             # Repository interfaces
β”‚   β”‚   └── usecases/                 # Use cases (business logic operations)
β”‚   β”‚
β”‚   β”œβ”€β”€ presentation/                 # Presentation layer (UI)
β”‚   β”‚   β”œβ”€β”€ providers/                # State management (Riverpod)
β”‚   β”‚   β”‚   β”œβ”€β”€ account/              # Account-related state
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                 # Authentication state
β”‚   β”‚   β”‚   β”œβ”€β”€ home/                 # Home screen state
β”‚   β”‚   β”‚   β”œβ”€β”€ main/                 # Main navigation state
β”‚   β”‚   β”‚   β”œβ”€β”€ products/             # Products management state
β”‚   β”‚   β”‚   β”œβ”€β”€ theme/                # Theme state
β”‚   β”‚   β”‚   └── transactions/         # Transactions state
β”‚   β”‚   β”œβ”€β”€ screens/                  # UI screens
β”‚   β”‚   β”‚   β”œβ”€β”€ account/              # Account screens
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                 # Authentication screens
β”‚   β”‚   β”‚   β”œβ”€β”€ error/                # Error screens
β”‚   β”‚   β”‚   β”œβ”€β”€ home/                 # Home/POS screen
β”‚   β”‚   β”‚   β”œβ”€β”€ main/                 # Main navigation screen
β”‚   β”‚   β”‚   β”œβ”€β”€ products/             # Product management screens
β”‚   β”‚   β”‚   └── transactions/         # Transaction history screens
β”‚   β”‚   └── widgets/                  # Reusable UI components
β”‚   β”‚
β”‚   β”œβ”€β”€ firebase_options.dart         # Firebase configuration
β”‚   └── main.dart                     # App entry point
β”‚
β”œβ”€β”€ test/                             # Unit and widget tests
β”‚   β”œβ”€β”€ core/services/                # Service tests
β”‚   β”œβ”€β”€ data/                         # Data layer tests
β”‚   β”‚   β”œβ”€β”€ datasources/              # Datasource tests
β”‚   β”‚   └── repositories/             # Repository tests
β”‚   β”œβ”€β”€ domain/usecases/              # Usecase tests
β”‚   └── presentation/screens/         # Screen tests
β”‚
β”œβ”€β”€ assets/                           # Static assets
β”œβ”€β”€ android/                          # Android platform files
β”œβ”€β”€ ios/                              # iOS platform files
β”œβ”€β”€ linux/                            # Linux platform files
β”œβ”€β”€ macos/                            # macOS platform files
β”œβ”€β”€ web/                              # Web platform files
β”œβ”€β”€ windows/                          # Windows platform files
β”‚
β”œβ”€β”€ analysis_options.yaml             # Dart analyzer configuration
β”œβ”€β”€ pubspec.yaml                      # Package dependencies
└── README.md                         # Project documentation

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/elrizwiraswara/flutter_pos.git
    cd flutter_pos
  2. Install dependencies:

    flutter pub get
  3. Set up Firebase:

    • Create a new project on Firebase.
    • Follow the instructions to add Firebase to your Flutter app here.
    • Enable google authentication provider
    • Update cloud firestore rules to allow read write operation
    service cloud.firestore {
      match /databases/{database}/documents {
        match /{document=**} {
          allow read, write: if request.auth != null;
        }
      }
    }
    
    • Add cloud firestore indexes to enable query
      Cloud Firestore Indexes

    • Update firebase storage rules to allow read write operation
    service firebase.storage {
      match /b/{bucket}/o {
        match /{allPaths=**} {
          allow read, write: if request.auth != null;
        }
      }
    }
    
  4. Set up your config.json file
    GOOGLE_SERVER_CLIENT_ID is Web client ID that you can get from your Firebase Google sign-in method provider

    {
      "GOOGLE_SERVER_CLIENT_ID": "xxxxxxxxxxxxx.apps.googleusercontent.com"
    }
    
  5. Run the application:

    flutter run --dart-define-from-file config.json

Test

To test the application, run the following command:

flutter test --coverage

To view the test coverage you can use genhtml or test_cov_console

AI Agent Guidelines

This project includes documentation files designed for AI coding agents (e.g., Claude Code) to keep code consistent when modifying the project:

  • CLAUDE.md β€” Project conventions (architecture, naming, code style)
  • UI.md β€” UI reference (layouts, components, design specs)
  • DATABASE.md β€” Database schema reference (tables, columns)
  • WORKFLOW.md β€” Git workflow (commits, branches, PRs)

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs, feature requests, or improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A Point of Sale (POS) application built with Flutter, demonstrating Clean Architecture principles and offline-first design patterns.

Topics

Resources

License

Stars

192 stars

Watchers

4 watching

Forks

Sponsor this project

 

Contributors