A production-ready Flutter application template with a robust architecture and essential features pre-configured.
- BLoC Pattern with Base Implementation
- Environment Flavors (Development, Staging, Production)
- Push Notifications with Firebase Cloud Messaging
- Theme Management
- Routing System
- Error Handling
- Logging
- Environment Configuration
- Visual Environment Indicators
lib/
├── core/ # Core functionality and base classes
├── modules/ # Feature modules
├── routes/ # Navigation and routing
├── services/ # Services (Push notifications, Database, etc.)
├── utils/ # Utilities and helpers
│ ├── config/ # Configuration (Flavors, Environment)
│ ├── networking/ # Network related utilities
│ └── theme/ # Theme configuration
└── main.dart # Application entry point
- Flutter SDK
- Android Studio / VS Code
- Firebase project (for push notifications)
- ImageMagick (for generating flavor-specific icons)
- Clone the repository:
git clone https://github.com/yourusername/flutter_base_template.git- Install dependencies:
flutter pub get- Set up environment variables:
cp .env.example .env.development
cp .env.example .env.staging
cp .env.example .env.production- Generate flavor-specific icons:
./scripts/generate_icons.shThe app supports three environments: development, staging, and production. Each environment has its own:
- App Icon
- App Name
- Environment Banner (except production)
- Configuration
The project includes a script to generate app icons for different environments:
# Navigate to the scripts directory
cd scripts
# Make the script executable
chmod +x generate_icons.sh
# Run the icon generation script
./generate_icons.sh- Place your custom logo at
assets/logo.png - If no logo is present, the script will download the Flutter logo
- Icons will be generated with a flavor-specific banner
chmod +x scripts/run.sh./scripts/run.sh development ./scripts/run.sh staging ./scripts/run.sh production - Ensure ImageMagick is installed:
# For Ubuntu/Debian sudo apt-get install imagemagick # For macOS brew install imagemagick
- Check Flutter and Dart SDK versions
- Verify script permissions with
chmod +x scripts/*.sh
.env.development- Development environment variables.env.staging- Staging environment variables.env.production- Production environment variables
- Development: Green banner with "development"
- Staging: Orange banner with "staging"
- Production: No banner
Each environment has its own distinctive app icon:
- Development: Green icon with "Dev" label
- Staging: Orange icon with "Staging" label
- Production: Blue icon
The project includes two GitHub Actions workflows:
-
Continuous Integration (
flutter-ci.yml):- Manually triggered workflow
- Validates code quality
- Runs tests
- Checks environment configuration
-
Continuous Deployment (
flutter-cd.yml):- Manually triggered workflow
- Builds APK and App Bundle
- Supports multiple flavors (development, staging, production)
- Validates environment configuration
scripts/setup-env.sh provides robust environment configuration:
- Validates environment file
- Checks required environment variables
- Supports different build flavors
- Provides informative environment setup logging
You can manually trigger workflows from the GitHub Actions tab:
- Select the desired flavor
- Optionally specify a custom environment file
- Run CI checks or build deployable artifacts
- Base BLoC implementation with error handling
- Standardized event and state management
- Automatic error logging
- Push Notification Service with Firebase integration
- Database Service for local storage
- Theme Service for dynamic theme management
- Route management using GoRouter
- Deep linking support
- Screen transitions
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project uses custom Git hooks to enforce code quality and commit message conventions.
Ensure you have the following tools installed:
- Flutter
- Dart
- Git
There are two methods to set up git hooks:
-
Make the hook script executable:
chmod +x scripts/git_hooks.sh
-
Set up symlinks using the script:
# From the project root directory ./scripts/git_hooks.sh setup-symlinks .
-
Optional: Test the git hooks
./scripts/git_hooks.sh test .
- Create symlinks manually:
# From the project root directory ln -sf ../../scripts/pre-commit .git/hooks/pre-commit ln -sf ../../scripts/commit-msg .git/hooks/commit-msg
The pre-commit hook performs comprehensive checks to maintain code quality:
- Prevents committing files larger than 5MB
- Blocks committing binary files
- Runs
flutter analyzeto check code quality - Executes
flutter testto ensure all tests pass
If any of these checks fail, the commit will be rejected with a detailed error message.
Commits must follow the Conventional Commits format with optional emoji:
[emoji] <type>(<optional scope>): <description>
| Gitmoji | Type | Description |
|---|---|---|
:art: |
Code Style | Improve structure / format of the code |
:zap: |
Performance | Improve performance |
:fire: |
Cleanup | Remove code or files |
:bug: |
Bugfix | Fix a bug |
:ambulance: |
Hotfix | Critical hotfix |
:sparkles: |
Feature | Introduce new features |
:memo: |
Documentation | Add or update documentation |
:rocket: |
Deployment | Deploy stuff |
:lipstick: |
UI | Add or update the UI and style files |
:tada: |
Initial | Begin a project |
:white_check_mark: |
Testing | Add, update, or pass tests |
:lock: |
Security | Fix security or privacy issues |
:closed_lock_with_key: |
Secrets | Add or update secrets |
:bookmark: |
Release | Release / Version tags |
:rotating_light: |
Linting | Fix compiler / linter warnings |
:construction: |
WIP | Work in progress |
:green_heart: |
CI | Fix CI Build |
:arrow_down: |
Downgrade | Downgrade dependencies |
:arrow_up: |
Upgrade | Upgrade dependencies |
:pushpin: |
Pin | Pin dependencies to specific versions |
:construction_worker: |
Build | Add or update CI build system |
:chart_with_upwards_trend: |
Analytics | Add or update analytics or track code |
:recycle: |
Refactor | Refactor code |
:heavy_plus_sign: |
Dependency | Add a dependency |
:heavy_minus_sign: |
Dependency | Remove a dependency |
:wrench: |
Config | Add or update configuration files |
:hammer: |
Scripts | Add or update development scripts |
:globe_with_meridians: |
I18n | Internationalization and localization |
:pencil2: |
Typo | Fix typos |
:rewind: |
Revert | Revert changes |
:truck: |
Move | Move or rename resources |
:page_facing_up: |
License | Add or update license |
:boom: |
Breaking | Introduce breaking changes |
:wheelchair: |
Accessibility | Improve accessibility |
:bulb: |
Comments | Add or update comments in source code |
:loud_sound: |
Logging | Add or update logs |
:mute: |
Logging | Remove logs |
:children_crossing: |
UX | Improve user experience / usability |
:building_construction: |
Architecture | Make architectural changes |
:iphone: |
Responsive | Work on responsive design |
:see_no_evil: |
Gitignore | Add or update a .gitignore file |
:alembic: |
Experiment | Perform experiments |
:mag: |
SEO | Improve SEO |
:label: |
Types | Add or update types |
:goal_net: |
Error | Catch errors |
:dizzy: |
Animation | Add or update animations and transitions |
:passport_control: |
Auth | Work on authorization, roles and permissions |
:adhesive_bandage: |
Patch | Simple fix for a non-critical issue |
:coffin: |
Dead Code | Remove dead code |
:test_tube: |
Test | Add a failing test |
:necktie: |
Business | Add or update business logic |
:technologist: |
DX | Improve developer experience |
:safety_vest: |
Validation | Add or update code related to validation |
# Feature with Gitmoji
:sparkles: feat: add user authentication
# Fix with scope and Gitmoji
:bug: fix(login): resolve password reset issue
# Documentation update with Gitmoji
:memo: docs: update README with setup instructions# Simple gitmoji commit
:sparkles: add user authentication feature
# Commit with scope
:bug:(login): resolve authentication error
# Commit with detailed description
:memo:(readme): update project documentation with new guidelines# Feature without emoji
feat: implement dark mode
# Fix with scope
fix(auth): resolve login validation bug
# Documentation update
docs: clarify installation steps# ❌ Missing type
just a random commit message
# ❌ Invalid type
unknown: add some changes
# ❌ Missing description
feat:
# ❌ Incorrect format
FEAT add new featureThe Git hooks will:
- Validate commit message format
- Check for valid commit types
- Optionally validate emoji (if used)
- Ensure meaningful commit descriptions
- Use present tense: "add feature" not "added feature"
- Be concise but descriptive
- Reference issue numbers if applicable
- Use emojis to add visual context (optional)
- Emojis are completely optional
- Can be placed at the start of the commit message
- Provide visual context to commit type
- Must be followed by a space before the type
- If a commit is rejected, carefully read the error message
- Ensure your code passes all checks before committing
- For formatting issues, run
dart format .to automatically fix most formatting problems
- Implement comprehensive test suite
- Set up flavors for different environments (development, staging, production)
- Implement Commit Hooks
- Configure CI/CD pipeline for automatic apk building and publishing
- Add more documentation and examples
- Implement analytics integration
- Add offline support
- Implement automated testing workflows
This project uses themes and design inspiration from Nylo, an open-source Flutter framework. Special thanks to the Nylo team for their excellent theming and design resources.
This project is licensed under the MIT License - see the LICENSE file for details.