Menu

Feature Packages

Relevant source files

This document provides an overview of the feature-specific packages in the Flutter Mobile Project Template. Feature packages are modular, self-contained components that implement specific functionality within the application. Each feature package follows a consistent structure and pattern while remaining focused on a single responsibility.

For information about core packages that provide foundational functionality across multiple features, see Core Packages.

Feature Package Architecture

Feature packages follow a modular architecture pattern that promotes separation of concerns. Each feature package is designed to be self-contained while leveraging the shared functionality provided by core packages.

Structure of a Feature Package

Sources: packages/features/setting/pubspec.yaml1-48 packages/features/debug_mode/pubspec.yaml1-41 packages/features/maintain/pubspec.yaml1-44 packages/features/force_update/pubspec.yaml1-36

Each feature package typically consists of the following components:

DirectoryPurpose
l10n/Feature-specific localization strings
domain/Models and business logic
data/Data repositories, API clients
provider/State management using Riverpod
ui/UI components and screens

Feature packages are organized around business domains rather than technical layers, making the codebase more maintainable and scalable.

Dependencies and Integration

Sources: apps/app/pubspec.yaml1-63 packages/features/setting/pubspec.yaml1-48 packages/features/debug_mode/pubspec.yaml1-41

Available Feature Packages

Setting Feature

The Setting feature provides functionality for user preferences and application configuration, including theme selection. It includes a settings screen where users can select different theme modes and view application information.


Sources: packages/features/setting/lib/src/ui/setting_page.dart1-94 packages/features/setting/lib/src/ui/components/setting_section_title.dart1-25 packages/features/setting/lib/src/ui/components/setting_section_spacer.dart1-17

The SettingPage provides UI for:

  • Theme selection (system, light, dark)
  • Application information (version)
  • Open source license information

Debug Mode Feature

The Debug Mode feature provides development tools and utilities that are only accessible in debug builds. It helps developers test various application states and navigate through the app.


Sources: packages/features/debug_mode/lib/src/ui/debug_page.dart1-90 packages/features/debug_mode/lib/src/ui/navigation_debug_page.dart1-119 packages/features/debug_mode/lib/ui.dart1-3

The Debug Mode feature provides functionality for:

  • Triggering error states
  • Enabling maintenance mode for testing
  • Testing force update functionality
  • Navigation debugging to any route in the application

Force Update Feature

The Force Update feature handles version checking and enforcing app updates when required. It compares the current app version against target versions for different platforms and determines if a user needs to update.


Sources: packages/features/force_update/lib/src/model/force_update_settings_state.dart1-28 packages/features/force_update/lib/force_update.dart1-6 packages/features/force_update/test/model/force_update_settings_state_test.dart1-426

The Force Update feature handles:

  • Semantic versioning comparison
  • Platform-specific version targeting (iOS and Android)
  • Displaying force update screens when updates are required

Maintain Feature

The Maintain feature handles application maintenance states, allowing the app to display a maintenance screen when backend services are unavailable or undergoing updates.

Sources: packages/features/maintain/pubspec.yaml1-44 packages/features/debug_mode/lib/src/ui/debug_page.dart1-90

Feature Package Integration

Feature packages are integrated into the main application through direct dependencies in the app's pubspec.yaml. Each feature package is designed to be independent but can interact with other features when necessary.

Sources: apps/app/pubspec.yaml12-43 packages/features/debug_mode/lib/src/ui/debug_page.dart1-90

Creating New Feature Packages

When creating new feature packages, follow these guidelines:

  1. Create a new package in the packages/features/ directory
  2. Follow the established package structure (l10n, data, domain, provider, ui)
  3. Keep features focused on a single responsibility
  4. Leverage core packages for shared functionality
  5. Use Riverpod for state management
  6. Add the new feature as a dependency in the app's pubspec.yaml

Additional functionality can be added through utility packages like the pagination utility found in packages/utils/pagination.

Sources: packages/utils/pagination/pubspec.yaml1-24 packages/samples/github_repository/pubspec.yaml1-36

Syntax error in textmermaid version 11.6.0
Syntax error in textmermaid version 11.6.0
Syntax error in textmermaid version 11.6.0