A Flutter counter application built with Feature-Sliced Design architecture. This example project demonstrates modern Flutter development patterns with Riverpod state management.
Flutter FSD Counter is a demo application that applies Feature-Sliced Design (FSD) architecture principles to the Flutter environment. It provides a scalable and maintainable codebase through hierarchical structure and feature-centric modularization.
- π― FSD Architecture: Organized code with systematic 6-layer structure
- π₯ Riverpod State Management: Modern and safe state management pattern
- π‘ Automatic Navigation: Smart routing based on counter state
- π‘οΈ Type Safety: Immutable models and pattern matching with Freezed
- π± Material Design 3: Latest design system implementation
- π§ͺ Code Generation: Automated code generation with build_runner
- Flutter SDK:
>=3.5.0 <4.0.0
- Dart: Modern object-oriented language
- Material Design 3: Google's latest design system
- riverpod: - State management
- flutter_riverpod: - Riverpod integration for Flutter
- go_router: - Declarative routing
- freezed: - Immutable class generation
- json_annotation: - JSON serialization
- build_runner: - Code generation tool
- freezed_annotation: - Freezed annotations
- json_serializable: - JSON serialization generation
- flutter_lints: - Code quality tools
lib/
βββ app/ # App layer - Global configuration
β βββ router/ # GoRouter navigation setup
β βββ theme/ # Material Design theme
βββ entities/ # Entities layer - Business models
β βββ counter/ # Counter entity
β βββ api/ # API interfaces
β βββ model/ # Freezed models
β βββ providers/ # State providers
βββ features/ # Features layer - Business features
β βββ increment/ # Increment feature
β βββ decrement/ # Decrement feature
β βββ reset/ # Reset feature
β βββ display/ # Display feature
β βββ start/ # Start feature
β βββ stop/ # Stop feature
βββ pages/ # Pages layer - Route pages
β βββ home/ # Home page
β βββ counter/ # Counter page
βββ widgets/ # Widgets layer - Reusable UI
β βββ controller/ # Composite controllers
β βββ app_bars/ # App bar components
βββ shared/ # Shared layer - Common resources
βββ providers/ # Global providers
βββ ui/ # Common UI components
- Flutter SDK: 3.5.0 or higher
- Dart SDK: 3.5.0 or higher
- IDE: VS Code or Android Studio recommended
# Clone the repository
git clone <repository-url>
cd flutter_fsd_counter
# Install dependencies
flutter pub get
# Generate code (Freezed models)
flutter packages pub run build_runner build --delete-conflicting-outputs
Check Flutter installation status:
flutter doctor
Check available devices:
flutter devices
# Run in development mode
flutter run
# Run in release mode
flutter run --release
# Run web version
flutter run -d web
# Run on specific device
flutter run -d <device-id>
- The home screen is displayed when the app starts
- Press the "Start Counter" button to navigate to the counter screen
- + button: Increment counter value
- - button: Decrement counter value
- Reset button: Reset counter to 0
- Stop button: Return to home screen
Screens automatically transition based on counter state (CounterStatus
):
stopped
: Displays home screenrunning
: Displays counter screen
- App: Global configuration (router, theme)
- Entities: Business entities and APIs
- Features: Independent business features
- Pages: Route-level page composition
- Widgets: Reusable UI components
- Shared: Common utilities and resources
- Upper layers depend only on lower layers
- No direct dependencies between features (via Entities/Shared)
- Clean interfaces through
index.dart
files
# Run all tests
flutter test
# Run specific test file
flutter test test/widget_test.dart
# Run tests with coverage
flutter test --coverage
# One-time build
flutter packages pub run build_runner build
# Watch mode for file changes
flutter packages pub run build_runner watch
# Build with conflict resolution
flutter packages pub run build_runner build --delete-conflicting-outputs
# Run static analysis
flutter analyze
# Check dependency tree
flutter pub deps
# Update dependencies
flutter pub upgrade
# Build Android APK
flutter build apk
# Build iOS app (macOS only)
flutter build ios
# Build web app
flutter build web
# Build APK
flutter build apk --release
# Build App Bundle (recommended)
flutter build appbundle --release
# Build iOS app
flutter build ios --release
# Build web app
flutter build web --release
- π΄ Fork the Project
- π Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - πΎ Commit your Changes (
git commit -m 'feat: Add some AmazingFeature'
) - π€ Push to the Branch (
git push origin feature/AmazingFeature
) - π Open a Pull Request
- Follow FSD architecture principles
- Use Riverpod state management patterns
- Utilize Freezed models
- Define interfaces through
index.dart
files - Adhere to Flutter lints rules
This project is distributed under the MIT License.
Hardy - Flutter Developer
- Feature-Sliced Design community for architecture guidelines
- Riverpod team for excellent state management solution
- Flutter team for continuous framework improvements
For questions or suggestions about the project, please create an issue.
- Feature-Sliced Design Official Documentation
- Riverpod Official Documentation
- Flutter Official Documentation
- Freezed Package
- GoRouter Package
β If you find this project useful, please give it a star! β