A modern Flutter application template implementing a Unified API Architecture that eliminates 90% of boilerplate while maintaining clean architecture benefits. Perfect starting point for scalable mobile and web applications with real API integration.
This project demonstrates a revolutionary unified approach that replaces traditional Clean Architecture complexity:
- 2 files per API instead of 12+ files
- Generic base classes for all CRUD operations
- Centralized provider management with type safety
- Unified error handling with consistent UX
- Real API integration with JSONPlaceholder
Example: Complete Users and Posts features with full CRUD operations, demonstrating the power of unified architecture patterns.
π― Unified API Architecture:
- β Generic DataListState for type-safe state management
- β ApiServiceFactory for automatic CRUD operations
- β
Centralized providers in
core/providers/api_providers.dart
- β
Unified error handling with
ErrorApiWidget
- β 90% less boilerplate compared to traditional Clean Architecture
π§ Modern State Management:
- β Riverpod for dependency injection and state management
- β
Generic StateNotifiers with
DataListNotifier<T>
- β Automatic API operations (GET, POST, PUT, DELETE)
- β Real-time error handling and retry functionality
π¦ Production-Ready Setup:
- β Multi-platform support (Android, iOS, Web)
- β Real API integration with JSONPlaceholder
- β Comprehensive test suite (30+ tests)
- β Facebook-inspired Material 3 theming
- Flutter SDK
- VS Code with Flutter extension
- Android Studio (for Android development)
- Xcode (for iOS development on macOS)
- Git (for version control)
-
Use this template for a new project:
git clone https://github.com/CoreProc/flutter-base.git your-new-project cd your-new-project
-
Customize for your project:
# Remove existing git history (optional) rm -rf .git # Initialize new git repository git init # Update project name in pubspec.yaml # Update README.md with your project details
-
Install dependencies:
flutter pub get
-
Run the app:
# For Android flutter run -d android # For iOS (macOS only) flutter run -d ios # For Web flutter run -d chrome
When using this base for a new project:
-
Update Project Details:
- Modify
pubspec.yaml
with your project name and details - Update
README.md
with your project description - Customize app icons and splash screens
- Modify
-
Configure Platforms:
- Update Android package name in
android/app/build.gradle.kts
- Update iOS bundle identifier in
ios/Runner.xcodeproj/project.pbxproj
- Modify web title and description in
web/index.html
- Update Android package name in
-
Add Dependencies:
- Add required packages to
pubspec.yaml
- Configure any platform-specific dependencies
- Add required packages to
Want to add a new API? Here's how easy it is with the unified architecture:
β features/products/data/datasources/...
β features/products/data/models/...
β features/products/data/repositories/...
β features/products/domain/entities/...
β features/products/domain/repositories/...
β features/products/domain/usecases/...
β features/products/presentation/pages/...
β features/products/presentation/providers/...
β
// 1. Create model (lib/models/product.dart)
class Product {
final int id;
final String name;
// ... add fromJson/toJson
}
β
// 2. Add provider (lib/core/providers/api_providers.dart)
static final productsProvider = ApiServiceFactory.createListProvider<Product>(
ApiConfig<Product>(
endpoint: '/products',
fromJson: (json) => Product.fromJson(json),
toJson: (product) => product.toJson(),
getId: (product) => product.id,
),
);
That's it! You now have full CRUD operations with loading states, error handling, and type safety. π
flutter run
- Run the app on connected deviceflutter run -d chrome
- Run on web browserflutter test
- Run all tests (30+ comprehensive tests)flutter build apk
- Build Android APKflutter build ios
- Build iOS app (macOS only)flutter build web
- Build for web deploymentflutter clean
- Clean build files
lib/
βββ core/ # Core unified architecture
β βββ api/api_service.dart # Generic API service factory
β βββ baseui/error_api.dart # Centralized error widget
β βββ data/base_repository.dart # HTTP operations
β βββ errors/failures.dart # Error classes
β βββ network/api_client.dart # Dio client configuration
β βββ providers/api_providers.dart # Centralized providers β
β βββ state/base_state.dart # Generic state classes
βββ models/
β βββ post.dart # Post model with JSON serialization
β βββ user.dart # User model with nested objects
βββ pages/
β βββ posts_page.dart # Posts UI with CRUD operations
β βββ users_page.dart # Users UI with rich details
βββ home_page.dart # Navigation hub
βββ main.dart # App entry point with Material 3 theme
test/ # Comprehensive test suite
βββ widget_test.dart # App and navigation tests
βββ core/ # Core system tests
β βββ baseui/error_api_test.dart # Error widget tests
β βββ providers/api_providers_test.dart # Provider tests
β βββ state/base_state_test.dart # State management tests
βββ models/ # Model serialization tests
βββ post_test.dart
βββ user_test.dart
Traditional Clean Architecture Problems:
- β 12+ files per API endpoint
- β Repetitive boilerplate code
- β Complex folder structures
- β Difficult to maintain consistency
- β Slow feature development
Unified Architecture Solutions:
- β 2 files per API endpoint (90% reduction!)
- β Generic base classes eliminate repetition
- β Centralized provider management
- β Consistent error handling and UX
- β Rapid feature development
- Development Speed: 5x faster API integration
- Code Maintainability: 90% less boilerplate to maintain
- Learning Curve: New developers productive in hours, not days
- Bug Reduction: Centralized patterns reduce common errors
- Type Safety: Full generic type safety with IntelliSense support
- β Android - Full native Android app support
- β iOS - Full native iOS app support
- β Web - Progressive Web App (PWA) support
This repository showcases the future of Flutter architecture:
- For new projects: Clone and adapt the unified patterns
- For learning: Study how to eliminate architectural complexity
- For teams: Establish consistent, maintainable development patterns
- β‘ Lightning-fast setup - Complete API integration in minutes
- π― Proven patterns - Battle-tested unified architecture
- π Production ready - Comprehensive error handling and testing
- π Extensive documentation - Multiple guides and examples
- π§ͺ Test coverage - 30+ tests covering all scenarios
- π¨ Modern UI - Material 3 with Facebook-inspired theming
SIMPLIFIED_API_GUIDE.md
- Complete guide to the unified API systemNEW_VS_OLD_ARCHITECTURE.md
- Detailed comparison with traditional approachesTEST_DOCUMENTATION.md
- Comprehensive test suite documentation
This unified architecture template welcomes improvements and enhancements:
- Fork the repository
- Create your feature branch (
git checkout -b feature/UnifiedImprovement
) - Commit your changes (
git commit -m 'Add unified architecture enhancement'
) - Push to the branch (
git push origin feature/UnifiedImprovement
) - Open a Pull Request
- Additional API patterns and examples
- Enhanced error handling strategies
- Performance optimizations
- Additional platform integrations
- Documentation improvements
This project represents a paradigm shift in Flutter development:
Instead of fighting complexity, we eliminated it.
Traditional Clean Architecture, while well-intentioned, often creates more problems than it solves for typical API-driven applications. This unified approach maintains all the benefits (testability, maintainability, scalability) while eliminating the pain points (boilerplate, complexity, slow development).
Perfect for:
- β API-driven mobile applications
- β Teams wanting rapid development without sacrificing quality
- β Projects requiring consistent error handling and UX
- β Developers who prefer working with real code over abstract patterns
This project template is open source and available under the MIT License.
π Ready to experience the future of Flutter architecture?
Clone this repository and build your next API-driven application in record time!