formix 0.0.6
formix: ^0.0.6 copied to clipboard
An elite, type-safe, and ultra-reactive form engine for Flutter powered by Riverpod.
0.0.6 #
π Documentation Improvements #
- Enhanced Headless Documentation:
- FormixFieldStateSnapshot.valueNotifier: Added comprehensive documentation with practical examples showing how to use
ValueListenableBuilderfor granular reactivity and optimized rebuilds. - FormixRawNotifierField: Complete class documentation explaining its purpose as a performance-optimized widget for ValueNotifier-based updates, with detailed examples demonstrating the difference between full rebuilds and granular updates.
- Cookbook Section: Added extensive "Headless Widgets" cookbook with three production-ready patterns:
FormixRawFormFieldfor custom controls (star rating example)FormixRawTextFieldfor custom text inputs (feedback field with character counter)FormixRawNotifierFieldfor performance optimization (counter with granular rebuilds)
- Updated Example App: Completely rewrote the headless form example to showcase all
FormixFieldStateSnapshotproperties with real-time state indicators and latest API usage. - Table of Contents: Added Cookbook section to README with proper navigation links.
- FormixFieldStateSnapshot.valueNotifier: Added comprehensive documentation with practical examples showing how to use
0.0.5 #
π DevTools Extension Redesign (v2) #
- Premium UI: Completely overhauled the DevTools extension with a modern, tabbed interface (Fields, Dependencies, Raw State).
- Glassmorphic Aesthetics: Implemented a premium design system with transparency, blur effects, and full support for Dark/Light modes.
- Enhanced Inspection:
- Raw State Tab: Inspect structured, nested form data in real-time (powered by
toNestedMap). - Dependency Graph: Visualized field relationships showing exactly what a field depends on and what it affects.
- Status Badges: Circular indicators for Dirty, Touched, and Pending states.
- Performance Metrics: Reactive validation duration labels with color-coded status.
- Raw State Tab: Inspect structured, nested form data in real-time (powered by
- Integrated refreshing: New auto-refresh logic with customizable intervals (1s-10s) and a dedicated sync indicator.
- formDataProvider: Added a reactive provider to expose the entire
FormixDatastate.
β¨ Accessibility & Semantics (shadcn-inspired) #
- Form Semantics: The
Formixwidget now automatically reports as aSemanticsRole.form, improving structural navigation for screen readers. - Validation Semantics: All fields (including headless ones) now communicate their validation status (
invalid/valid) directly to the OS viaSemanticsValidationResult. - Intelligent Announcements: Added
FormixController.announceErrors()which automatically reads out the first validation error to assistive technologies when a submission fails.
π Standard Field Properties #
- Unified API: All Formix fields (
Text,Number,Checkbox,Dropdown) now support standardFormFieldproperties:onSaved&onResethooks.enabledstate management.forceErrorTextfor manual error overrides.errorBuilderfor custom error UI.autovalidateModefor per-field validation control.restorationIdfor state restoration.
- Explicit Controller: The
Formixwidget now supports an optional explicitcontrollerparameter, allowing for manual instantiation while keeping the reactive provider benefits.
π οΈ Core Improvements & Fixes #
- Headless API:
FormixFieldStateSnapshotnow exposesenabledanderrorBuilder, making it easier to build high-quality custom components. - Validation Fix: Fixed
RiverpodFormController.registerFieldto strictly honorautovalidateModeduring initial registration, preventing unwanted errors indisabledforms. - Type-Safe Value Retrieval:
- Reverted
getValue<T>to returnT?for better safety and backwards compatibility. - Added "smart fallback" to
getValue: now recovers values frominitialValueMapor field definitions if a field is not yet registered. - Introduced
requireValue<T>: returnsTand throws a descriptiveStateErrorif the value is null.
- Reverted
- New Field Transformers:
FormixFieldTransformer: Synchronous 1-to-1 transformation between fields.FormixFieldAsyncTransformer: Asynchronous transformation with built-in debounce and robust lifecycle management.
- Hot Reload Support: Fixed field definitions not updating during hot reload.
FormixandFormixSectionnow reliably detect configuration changes and update the controller. - Riverpod Refactors: Key widgets (
FormixFieldDerivation,FormixGroup,FormixListener) upgraded toConsumerStatefulWidgetfor better state access. - Hot Reload Support: Fixed field definitions not updating during hot reload.
FormixandFormixSectionnow reliably detect configuration changes and update the controller. - FormixSection Overhaul: Refactored to
ConsumerStatefulWidgetfor consistent lifecycle management.- Now supports synchronous registration to prevent lazy-loading race conditions.
- Reliably handles
keepAlivefor preserving state in wizards and tabs.
- Undo/Redo Stability: Fixed history pollution where focus/touch events triggered unnecessary undo steps. History is now strictly value-based using deep equality checks.
- Validation Fixes:
FormixAutovalidateMode.alwaysnow correctly shows errors immediately upon registration for all field types.- Fixed input formatter ordering in
FormixTextFormFieldandFormixNumberFormFieldto ensure config-level formatters (logic) run before widget-level formatters (UI).
- New
FormixAsyncField: Added a dedicated widget for handling asynchronous data fetching within forms.- Features built-in race condition protection and retry logic.
- Automatically re-triggers fetch on form reset (via
onRetry). - Coordinated with the form's
isPendingstate for submission safety.
- New
FormixDependentAsyncField: A simplified widget for parent-child field relationships.- Automatically watches a dependency and executes a future.
- Improved Robustness: Fixed lifecycle issues where fields could occasionally unregister during rapid state transitions.
- Supports
resetFieldto automatically clear dependent fields when the parent changes.
- Robust Reset Logic: Form resets are now tracked via an internal
resetCount, ensuring theonResethook is reliably triggered for all fields regardless of their previous dirty state. - Improved Pending State Management: Fixed "Tried to modify a provider while the widget tree was building" error by moving pending state updates to microtasks.
- Multi-Step Form Reliability: Fixed a bug where navigating back to a previous page in a multi-step form would show "required" validation errors even if fields were filled. Formix now correctly validates against preserved values during re-registration.
- Dropdown Field: Migrated
FormixDropdownFormFieldto useInputDecorator+DropdownButton. Now defensively handles values not present in the items list to prevent crashes during dynamic transitions. - Global Validation Mode:
- Introduced form-level
autovalidateModeinFormixwidget andFormixController. - Added
FormixAutovalidateMode.autoas the default for all fields, allowing them to inherit the form's global setting or explicitly override it. - Improved
onUserInteractionlogic to ensure consistent feedback when values are changed and then reverted to their initial state.
- Introduced form-level
- Infinite Loop Fix: Optimized
FormixControllerlistener notifications to prevent infinite loops when fields trigger state changes during updates (e.g., inFormixFieldAsyncTransformer). - Robust Bulk Update API:
- Added
FormixBatchfor compile-time type-safe batch building with a new fluentsetValue().to()API for guaranteed lint enforcement. - Added
FormixBatchResultfor detailed reporting on batch failures (type mismatches, missing fields). - Both
setValuesandupdateFromMapnow return results instead of throwing, with an optionalstrict: truemode for developers who prefer immediate crashes during debugging.
- Added
- High-Performance Dependency Tracking:
- Re-engineered
_collectTransitiveDependentswith a high-speed BFS implementation using an index-based queue, reducing traversal time for 100,000-field chains from 332ms to ~160ms. - Optimized internal dependents map access with zero-allocation iterables.
- Re-engineered
- Async Validation Stability:
- Fixed a critical race condition where
submit()could hang indefinitely if called while an async validation was already pending. - Corrected
pendingCountdouble-increment bug during concurrent validation cycles. - Consolidated "validating" state transitions into primary batch updates, eliminating redundant UI rebuilds.
- Fixed a critical race condition where
- Optimized State Engine:
- Implemented Lazy Map Cloning for validation results, avoiding O(N) penalties when field values change but validation results remain constant.
- Shared
FormixDatavalidation contexts across batch updates to drastically reduce GC pressure in cross-field validation chains. - Replaced functional filter/map operations in hot paths with high-performance manual loops for count calculations.
- Validation Fixes:
- Fixed
onUserInteractionmode regression where valid results weren't properly cached to track the "previously validated" state. - Corrected
FormixAutovalidateMode.alwaysbehavior during initial field registration.
- Fixed
- DevTools Integration: Forms without an explicit
formIdnow automatically register with DevTools using their internal namespace as a fallback, ensuring full visibility.
π οΈ Developer Experience #
- FormixBuilder Enhancements: Improved reactive data access patterns with better scoping.
- New
FormixWidget: Added base class for creating reusable, context-aware form components with less boilerplate.
π§ͺ Testing #
- Advanced Async Test Suite: Added comprehensive tests for
FormixDependentAsyncFieldandFormixAsyncField:- Rapid dependency change handling and debounce verification.
- State preservation during async loading unmounts.
- Validation error clearing on field resets.
- Additional Test Coverage:
- Dynamic Array Fields (Contacts List)
- Multi-Step Wizards with State Preservation
- Complex Validation Scenarios & Input Formatting
- Hot Reload & Lifecycle Behavior
- Performance & Memory Leaks (5000+ fields, rapid typing stress tests)
0.0.4 #
π οΈ DevTools Integration #
- DevTools Extension: Added a dedicated DevTools extension for real-time form state inspection and debugging
- π Visual form state tree with field values, validation states, and metadata
- β‘ Performance monitoring for form rebuilds and validation execution
- π Deep link integration for quick access from running applications
- π Built with Flutter Web and fully integrated with the DevTools ecosystem
π Type Safety & Reliability #
- Strict Null Safety: Comprehensive null-safety across all validators and widgets
- Integration Testing: Expanded integration tests for complex scenarios
π― User Experience Enhancements #
- Rich Error Placeholders: Dynamic errors like
Field {label} must be at least {min} characters - Built-in Masking & Formatting: Input formatters in
FieldConfig - Automatic Focus Management: Submit-to-Error and Enter-to-Next implemented
π§ Advanced State Management #
-
Undo/Redo History: Snapshots for state restoration and history
-
Optimistic Field Updates: Pending state for server round-trips
-
Multi-Form Synchronization: "Binding" API to link fields between separate forms
-
Improved error messages and validation feedback
-
Fluent Validators: New
FormixValidatorsAPI for readable chainable rules -
Logging Analytics: Built-in debug logger for form events
-
Robust Dependency Logic: Support for recursive A->B->C dependency chains with cycle detection. Optimized to O(N) (10,000-field chain updates in ~70ms).
-
Correct Undo/Redo Behavior: Implemented semantic equality for form state to prevent duplicate history entries.
-
Async Submission Safety:
submit()now waits for all pending async validations to complete before proceeding -
Partial Validation:
validate(fields: [...])allows validating specific subsets of fields (e.g., for Steppers)
β‘ Performance Optimizations #
- Delta Updates: O(1) complexity for field updates (was O(N)), enabling forms with 1000+ fields
- Lazy Step Initialization: "Sleep" background steps to save memory in 50+ step forms
- Form Analytics Hook: Track completion time and abandonment points
- Built-in Localization: Support for 6 languages out-of-the-box (En, Es, Fr, De, Hi, Zh)
- Zero Configuration: Works automatically with standard Flutter
MaterialApp - Optional Delegate: New
FormixLocalizations.delegatefor seamless integration (completely optional) - Reviewable Messages: Fallback mechanism to
Localizations.localeOf(context)if delegate is missing
π§ Developer Experience #
- Enhanced visual debugging tools through DevTools extension
- Better form state introspection capabilities
- Improved error messages and validation feedback
0.0.3 #
- Upgraded flutter_riverpod to ^2.6.1
0.0.2 #
- Updated logo URL
0.0.1 #
β¨ Initial Release #
An elite, type-safe, and ultra-reactive form engine for Flutter powered by Riverpod.
π Core Features
- True Type Safety: Compile-time safety using
FormixFieldID<T>andFormixArrayID<T>. - High Performance: Granular rebuilds using Riverpod selectorsβonly affected widgets update.
- Auto-Disposable: Automatic memory management with Riverpod
autoDisposecontrollers. - Declarative API: Define form structure easily using
FormixFieldConfig.
π₯ Validation & Logic
- Smart Validation: Support for Sync, Async (with debounce), and Cross-field validation.
- Dependency Tracking: Automatic re-validation of dependent fields.
- Field Derivation: Computed fields based on other form values.
ποΈ Advanced UI Components
- Sectional Forms:
FormixSectionfor lazy-loading and organizing massive forms (100+ fields). - Form Arrays: Managed dynamic lists with type safety.
- Navigation Guard:
FormixNavigationGuardto prevent accidental data loss on dirty forms. - Performance Monitor:
FormixFieldPerformanceMonitorfor tracking widget rebuilds.
π― UX & Control
- Programmatic Focus: Jump to errors or specific fields via
FormixScope. - Automated Scrolling: Smooth scrolling to validation errors.
- State Persistence: Interface for saving/restoring form progress to local storage.
π§© Built-in Widgets
RiverpodTextFormFieldRiverpodNumberFormFieldRiverpodCheckboxFormFieldRiverpodDropdownFormFieldFormixDependentFieldFormixBuilderFormixWidget(Base class for custom components)