A POS (Point of Sale) application for business owners, built with Flutter. The project follows a layered architecture (presentation → application → domain → infrastructure) with dependency injection, state management, automated routing, internationalization, and code generation.
### Code generation (required after clone or when annotations change)
```bash
flutter pub run build_runner build --delete-conflicting-outputs
```
> Re-run whenever you change files using `@RoutePage()`, `@injectable`, `@freezed`, or `@JsonSerializable`.
---
## Running the App
```bash
flutter run
```
Select a specific device/platform:
```bash
flutter run -d chrome
flutter run -d ios
flutter run -d android
```
Example release builds:
```bash
flutter build apk --release
flutter build ios --release
flutter build web --release
```
---
## Architecture Overview
The codebase follows a clean, layered approach that separates concerns and keeps features modular and testable:
- Presentation (`lib/presentation`): Widgets, pages/screens, and the `AutoRoute` router. Contains only UI code and wiring to BLoC/Cubit.
- Application (`lib/application`): BLoC/Cubit and application-level orchestration. Holds input validation, state transitions, and calls into the Domain layer.
- Domain (`lib/domain`): Pure business logic. Entities, value objects, repository interfaces, and (optional) use-cases. No framework dependencies.
- Infrastructure (`lib/infrastructure`): Repository implementations, DTOs, and data sources (HTTP/DB). Performs `dio` calls and mappings between DTOs and Domain entities.
- Common (`lib/common`): Cross-cutting helpers such as API base, DI setup, constants, extensions, theme, validators, and utilities.
Data flow in a feature:
1. UI triggers an intent/event in Presentation →
2. Application layer BLoC/Cubit handles the event and calls a repository/use-case from Domain →
3. Infrastructure implements the repository, performs network calls via `dio`, and maps results →
4. Data is converted to Domain entities and returned to Application →
`flutter_gen_runner` is integrated with `build_runner`. Running the commands above will also generate typed accessors for assets based on the `flutter_gen` section in `pubspec.yaml`:
- Injectable: Generates DI registrations (`injection.config.dart`).
- Freezed: Generates immutable data classes, copyWith, unions, etc.
- Json Serializable: Generates toJson/fromJson for DTOs.
- FlutterGen: Generates static asset access under `lib/presentation/components/assets/`.
---
## Internationalization (i18n)
- Source files live in `lib/l10n/app_*.arb` (e.g., `app_en.arb`, `app_id.arb`).
- To add a language: create `app_<code>.arb`, then run code generation.
- Ensure `MaterialApp` is wired with `localizationsDelegates` and `supportedLocales` (already prepared).
---
## Theming & Assets
- Theme files live under `lib/common/theme/`.
- Fonts: `Quicksand` family is declared in `pubspec.yaml`.
- Assets: `assets/images/`, `assets/icons/`, `assets/json/`– referenced via FlutterGen outputs at `lib/presentation/components/assets/`.
---
## Environment Configuration (`env.dart`)
The `lib/env.dart` file stores configuration values such as base URLs and debug flags. Adjust per environment (development/production) using flavors, environment variables, or branching as preferred by the team.
---
## Development Practices
- Routing: Define routes in `presentation/router`, then run code generation.
- DI: Annotate services/repositories with `@injectable`/`@LazySingleton`, generate code, and call `configureDependencies()` early in app startup.
- BLoC: Keep UI logic in the `application` layer and use `BlocBuilder`/`BlocListener` in the `presentation` layer.
- DTO ↔ Entity: Mapping resides in the `infrastructure` layer to keep domain pure.
- Error handling: Prefer `Either`/`Option` (`dartz`) or well-structured BLoC states.
flutter pub run flutter_launcher_icons -f launcher_icon.yaml
```
Ensure you have the package in `dev_dependencies` (`flutter_launcher_icons`).
## Contributing
1. Branch off `main`.
2. Make focused changes and provide a clear PR description.
3. Ensure build, lints, and codegen are clean before opening the PR.
---
## License
This project is private/internal. Contact the repository owner for usage permissions.
## Apskel Owner Flutter
Aplikasi Point of Sale (POS) untuk pemilik usaha, dibangun dengan Flutter. Proyek ini menerapkan arsitektur berlapis (presentation → application → domain → infrastructure) dengan dependency injection, state management, routing terotomasi, internationalization, dan code generation.
> Jalankan ulang perintah di atas setiap kali Anda mengubah file yang menggunakan anotasi `@RoutePage()`, `@injectable`, `@freezed`, atau `@JsonSerializable`.
flutter pub run build_runner build --delete-conflicting-outputs
# atau untuk watch
flutter pub run build_runner watch --delete-conflicting-outputs
```
Generator yang digunakan:
- AutoRoute: menghasilkan deklarasi router & route.
- Injectable: menghasilkan registrasi DI (`injection.config.dart`).
- Freezed: menghasilkan data class immutable, copyWith, union, dsb.
- Json Serializable: menghasilkan toJson/fromJson untuk DTO.
- FlutterGen: menghasilkan akses asset statis di `lib/presentation/components/assets/`.
---
## Internationalization (i18n)
- Berkas sumber ada di `lib/l10n/app_*.arb` (contoh: `app_en.arb`, `app_id.arb`).
- Bahasa baru: tambahkan `app_<kode>.arb`, jalankan code generation.
- Pastikan `MaterialApp` menggunakan `localizationsDelegates` dan `supportedLocales` (sudah disiapkan).
---
## Theming & Assets
- Theme ada di `lib/common/theme/`.
- Font: keluarga `Quicksand` dideklarasikan di `pubspec.yaml`.
- Assets: `assets/images/`, `assets/icons/`, `assets/json/`– akses via FlutterGen yang dihasilkan ke `lib/presentation/components/assets/`.
---
## Konfigurasi Lingkungan (`env.dart`)
File `lib/env.dart` menyimpan nilai konfigurasi seperti base URL, flag debug, dll. Sesuaikan untuk development/production (bisa dengan flavor, env var, atau branch khusus sesuai kebutuhan tim).
---
## Praktik Pengembangan
- Routing: definisikan route di `presentation/router`, jalankan codegen.
- DI: daftarkan service/repository dengan anotasi `@injectable`/`@LazySingleton`, lalu generate, dan panggil `configureDependencies()` di awal aplikasi.
- BLoC: simpan logic UI di layer `application` dan gunakan `BlocBuilder`/`BlocListener` di layer `presentation`.
- DTO ↔ Entity: mapping berada di layer `infrastructure` untuk menjaga domain tetap bersih.
- Error handling: gunakan `Either`/`Option` (`dartz`) atau state terstruktur di BLoC.
- Lint: patuhi aturan `analysis_options.yaml`.
---
## Perintah Berguna
```bash
# Install dependencies
flutter pub get
# Format & Analyze
flutter format .
flutter analyze
# Code generation (sekali jalan / watch)
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run build_runner watch --delete-conflicting-outputs
# Run by device
flutter devices
flutter run -d <device-id>
```
---
## Catatan Tambahan
- Icon launcher dikonfigurasi di `launcher_icon.yaml` (gunakan `flutter pub run flutter_launcher_icons` bila diperlukan).
- Konfigurasi platform (Android/iOS/Web/Desktop) berada pada folder platform terkait.
- Pastikan meninjau `analysis_options.yaml` untuk standar code style dan lints.
---
## Kontribusi
1. Buat branch dari `main`.
2. Lakukan perubahan terfokus dan sertakan deskripsi yang jelas pada PR.
3. Pastikan build, lints, dan codegen bersih sebelum mengajukan PR.
---
## Lisensi
Proyek ini bersifat privat/internal. Hubungi pemilik repositori untuk detail izin penggunaan.