flutter_clean_mvvm_toolkit 0.2.1
flutter_clean_mvvm_toolkit: ^0.2.1 copied to clipboard
A comprehensive Flutter toolkit for Clean Architecture with MVVM pattern. Provides ViewModels, Use Cases, Entities, Error Handling, and CRUD patterns for scalable Flutter applications.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.2.1 - 2026-01-05 #
🔄 Changed #
- CrudViewModel: Refactored CRUD methods to return
Future<OperationResult<T>>instead ofboolorT?. This provides more context about the operation result, including errors and messages. - OperationResult: Converted to a generic class
OperationResult<T>to support typed data return and better error encapsulation. - OperationResultMixin: Added
handleResult<T>(result)method to automatically processOperationResultand notify listeners.
0.2.0 - 2026-01-05 #
🚨 Breaking Changes #
- Removed:
CrudPageViewModelandCrudFormViewModel(replaced with simpler architecture) - Changed:
EntityFormViewModel.mapDataToEntity()now returnsT?and validates automatically - Changed:
CrudViewModelno longer has direct dependency onEntityFormViewModel
✨ Added #
- New:
EntityFormViewModelwith automatic validation before entity creationbuildEntityFromForm(): New abstract method for entity constructionmapDataToEntity(): Now validates form before returning entity (returnsnullif invalid)
- New: Decoupled
CrudViewModelarchitecture- Methods now receive entities as parameters
- Returns explicit
boolorT?for better error handling - No dependency on FormViewModel
- New: Complete validation system with two layers:
FormValidators: UI validators returningString?for Flutter widgetsValidators: Business logic validators returningErrorItem?
- New: Additional validators:
validateMatch(): Compare two fields (e.g., password confirmation)validatePhone(): Phone number validationvalidateUrl(): URL format validationvalidatePasswordStrength(): Strong password requirementsvalidateAlphabetic(): Only letters and spacesvalidateNumeric(): Numeric valuesvalidateNotFutureDate(): Date cannot be in the futurevalidateRange(): Numeric range validationvalidateStringLengthRange(): String length between min and maxvalidateMaxLength(): Maximum string lengthvalidateNotNull(): Null check with ErrorItemvalidateModelNotNull(): Validates all Model fields are not null
- New:
Modelbase class for Data Transfer Objects (DTOs)
🔄 Changed #
- Widget coordination: Widgets now mediate communication between ViewModels
- Improved:
DefaultEntityFormdocumentation with multiple usage examples - Improved: Separation of concerns between form management and CRUD operations
📚 Documentation #
- Complete README rewrite with new architecture
- Added comprehensive examples for all features
- Added best practices section
- Added validation system documentation
- Updated all code examples to reflect new patterns
🎯 Migration Guide from 0.1.x #
Before (0.1.x):
class MyViewModel extends EntityFormViewModel<MyEntity>
implements CrudFormViewModel<MyEntity> {
@override
MyEntity mapDataToEntity() => MyEntity(...);
@override
Future<void> addEntity() async {
final entity = mapDataToEntity();
// CRUD logic here
}
}
After (0.2.0):
// Separate ViewModels
class MyFormViewModel extends EntityFormViewModel<MyEntity> {
@override
MyEntity buildEntityFromForm() => MyEntity(...);
// Only form management
}
class MyCrudViewModel extends CrudViewModel<MyEntity> {
@override
Future<bool> addEntity(MyEntity entity) async {
// CRUD logic here
return true;
}
}
// Coordinate in Widget
final entity = formViewModel.mapDataToEntity(); // Auto-validates
if (entity != null) {
await crudViewModel.addEntity(entity);
}
0.1.0 - 2026-01-02 #
Added #
- Initial release of Flutter Clean MVVM Toolkit
- Core domain components:
Entitybase class with EquatableUseCasefor Future-based business logicStreamUseCasefor reactive business logicNoParamsfor parameterless use cases
- Error handling system:
ErrorItemwith structured error representationErrorCodeenum for error categorizationErrorLevelEnumfor error severity levels
- Presentation layer components:
DefaultFormViewModelwith validation helpersCrudPageViewModelfor list/delete operationsCrudFormViewModelinterface for create/updateEntityFormViewModelwith ChangeNotifierOperationResultMixinfor success/failure handlingOperationSuccessandOperationFailureclassesFormTypeenum (create/update)DefaultEntityFormwidget base
- Utilities:
DataUtilsfor safe JSON parsing
- Complete documentation and examples
- MIT License