smart_multi_form_fields 1.1.0
smart_multi_form_fields: ^1.1.0 copied to clipboard
A single, production-grade Flutter form field widget rendering text, password, phone, OTP, date, dropdown, and file inputs via sealed configurations.
1.1.0 #
Added #
Password Field (SmartPasswordConfig / SmartPasswordFieldImpl)
- Production-grade password field rendering with full feature parity across login, signup, and reset forms.
- Animated Password Strength Meter: 4-segment color-coded strength bar (
SmartStrengthMeter) with live accessibility label announcements for screen readers. - Min Length Baseline: Password strength stays
WeakuntilminPasswordLengththreshold baseline is reached. - Granular Complexity Validation Rules: Opt-in rule flags (
requireUppercase,requireLowercase,requireDigit,requireSpecialChar). - Confirm Password Matching: Real-time exact string match validation via
confirmPasswordControllerand custom error message (confirmMismatchMessage). - Custom Obscuring Character:
obscuringCharacterproperty allowing developers to set custom mask characters (e.g.'*'or default'•'). - Visibility Toggle Customization:
showToggleIcontoggle andtoggleIconBuilderfor developer-supplied eye icons. - Custom Strength Scorer:
customStrengthScorercallback allowing developers to inject custom security policies overriding defaultPasswordStrengthScorer. - Custom Strength Meter UI:
strengthMeterBuildercallback allowing complete replacement of default 4-segment strength bar widget tree. - Custom Validators: Fully supports custom validator lists (
validators: [...]) running in sequence.
Performance & Memory Optimizations #
- Static Compiled RegExp Allocation: Optimized
PasswordStrengthScorerandSmartPasswordFieldImplregexes into compiledstatic finalconstants (uppercaseRegExp,lowercaseRegExp,digitRegExp,specialCharRegExp) to eliminate garbage collection allocations on rapid keystrokes. - Keystroke Re-render Threshold Guard: Added strength equality checks in
_onChangedto prevent unnecessary widget rebuilds when strength scores remain unchanged.
1.0.0 #
Initial release — Text field only. Password, Phone, OTP, Date, Dropdown, and File field types exist internally as part of the sealed configuration hierarchy (required for the type-safe dispatcher to compile) but are not part of the public API surface in this release and will ship in their own future versions.
Added #
Architecture
- Sealed configuration hierarchy (
SmartFieldConfig) for compile-time-safe, per-type config classes - Single dispatcher widget (
SmartFormField) — one widget for every field type - Template-method base shell (
SmartBaseShell/SmartBaseShellState) for consistent label/error/helper rendering
Text Field (SmartTextConfig / SmartTextFieldImpl)
- Label, hint, helper text, required-field asterisk
- Built-in validation chain: required check →
minLength→ custom validator list (first error wins) minLengthwith live "Minimum: N characters" hint that switches to the character counter once metmaxLengthwith live character counter, warning color near the limit- Multiline support via
maxLines/minLines, with correct handling of Flutter'smaxLines/minLinesconstraint - Auto-capitalization (
autoCapitalizeWords) via a cursor-position-preservingCapitalizeFormatter - Custom
inputFormatterssupport - Prefix icon, suffix icon with tap callback
readOnlymode (visible, focusable, not editable) distinct fromenabled: false(dimmed, not focusable)autofocus,autofillHints(password manager / browser autofill)- Keyboard type,
textCapitalizationhint, smarttextInputActiondefaulting (nextwhennextFocusNodeis set) - Focus traversal via
nextFocusNode onChanged,onSubmittedcallbacks
External Controller Support
- Optional
controllerproperty onSmartFieldConfig, mirroring the existingfocusNodepattern — if you provide aTextEditingController, you own its lifecycle and disposal; if omitted, the field creates and disposes its own internally
Theming — 3-Tier Decoration Resolution
- Every decoration property (borders, fill, label/hint/helper/error text styles) resolves in order: per-field override → your app's
Theme.of(context).inputDecorationTheme→ package's ownColorScheme-driven default - No custom
ThemeExtensionor registration step required — respects your app's existing Material theme automatically, including light/dark mode - Zero-width-space (
\u200B) technique for triggering the error border state without allocating extra layout space
Debounced & Async Search
SmartTextConfig.search(...)factory constructor — preset with search icon, auto-clear button,TextInputAction.search, and a sensible debounce defaultdebounce,onDebouncedChanged(sync/local filtering),onSearchAsync(async, e.g. API calls) properties available on anySmartTextConfig, not just the search preset- Race-condition-safe async search:
onSearchAsyncreceives anisCurrent()checker so a slow, older request can never overwrite a faster, newer one's results showSearchLoadingIndicator— auto-swaps the suffix icon to a spinner while a search is in flightshowClearButton— general-purpose auto clear (×) icon, available on any text field, not search-exclusive- Submitting (Enter / search key) cancels any pending debounce and fires the search callback immediately
Programmatic Control
GlobalKey<SmartBaseShellState>access pattern:validate(),value,reset(),setError(String?),clearError()
Known Limitations #
- Validation-message strings, tooltips, and strength-meter labels are hardcoded English — localization support is planned but not yet implemented
- No form-level controller yet (each field needs its own
GlobalKeyfor programmatic access; there is no aggregator for validate-all/get-all-values across multiple fields)