smart_multi_form_fields 1.0.0-alpha.1
smart_multi_form_fields: ^1.0.0-alpha.1 copied to clipboard
A single, production-grade Flutter form field widget rendering text, password, phone, OTP, date, dropdown, and file inputs via sealed configurations.
Smart Form Field (smart_multi_form_fields) #
A production-grade, type-safe Flutter form field package that provides a single public widget (SmartFormField) capable of rendering multiple input types through a sealed configuration hierarchy.
Current status: Text and Password fields are fully implemented. Phone, OTP, Date, Dropdown, and File are stubs only β their config classes exist (required for the sealed hierarchy to compile) but do not yet render functional widgets. See the status table below.
Implementation Status #
| Type | Config | Status |
|---|---|---|
| Text | SmartTextConfig |
β Complete |
| Password | SmartPasswordConfig |
π‘ Built, not yet published |
| Phone | SmartPhoneConfig |
β³ Not implemented |
| OTP | SmartOtpConfig |
β³ Not implemented |
| Date | SmartDateConfig |
β³ Not implemented |
| Dropdown | SmartDropdownConfig |
β³ Not implemented |
| File | SmartFileConfig |
β³ Not implemented |
Features (Text & Password) #
- π― Single Public Widget:
SmartFormField(config: ...)for every input type. - π Type-Safe Sealed Configs:
SmartFieldConfigis sealed β compile-time safety, zero dead properties. - π Built-in Validation: Required check,
minLength, custom validator chain, first-error-wins. - π External Controller: Optional
controllerproperty, same pattern asfocusNodeβ you own it if you provide it. - π¨ Automatic Theming: Matches your app's existing light/dark theme out of the box. If you've already styled your text fields via
InputDecorationTheme, this respects that too β no extra setup, no new concept to learn. - β± Debounced & Async Search:
SmartTextConfig.search()with race-condition-safe async handling. - π Programmatic Control: Validate, reset, read values via
GlobalKey<SmartBaseShellState>. - π Password Field: Visibility toggle, animated strength meter, complexity rules, confirm-match validation.
Not yet available: localization of package-generated strings (validation messages, tooltips) β currently hardcoded English. Dev-supplied strings (label/hint/helperText) already work with any localization approach since you provide them directly.
Installation #
dependencies:
smart_multi_form_fields: ^1.0.0-alpha.1
Usage #
import 'package:smart_multi_form_fields/smart_multi_form_fields.dart';
Basic Text Input #
SmartFormField(
config: SmartTextConfig(
label: 'Full Name',
hint: 'Enter your name',
isRequired: true,
autoCapitalizeWords: true,
),
)
External Controller #
final _controller = TextEditingController();
SmartFormField(
config: SmartTextConfig(label: 'Name', controller: _controller),
)
_controller.text = 'Pre-filled value'; // read/write from anywhere
// You provided the controller, so YOU dispose it:
_controller.dispose();
App-Wide Theming (Tier 2) #
MaterialApp(
theme: ThemeData(
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(borderRadius: BorderRadius.circular(16)),
filled: true,
fillColor: Colors.grey[100],
),
),
)
// Every SmartFormField now uses this automatically β no extra setup.
Async Search Field with Debounce #
SmartFormField(
config: SmartTextConfig.search(
label: 'Search',
hint: 'Type queryβ¦',
debounce: const Duration(milliseconds: 500),
onSearchAsync: (query, isCurrent) async {
final results = await myApi.search(query);
if (isCurrent()) { // required β discards stale results
setState(() => _searchResults = results);
}
},
),
)
Programmatic Validation #
final _key = GlobalKey<SmartBaseShellState>();
SmartFormField(key: _key, config: SmartTextConfig(label: 'Email', isRequired: true))
final error = _key.currentState?.validate();
if (error == null) {
final value = _key.currentState?.value;
}
Planned Architecture (Full Target) #
SmartFormField(config: SmartTextConfig(...)) β β
text input
SmartFormField(config: SmartPasswordConfig(...)) β β
password field
SmartFormField(config: SmartPhoneConfig(...)) β β³ phone + country code
SmartFormField(config: SmartOtpConfig(...)) β β³ OTP boxes
SmartFormField(config: SmartDateConfig(...)) β β³ date/time picker
SmartFormField(config: SmartDropdownConfig(...)) β β³ searchable dropdown
SmartFormField(config: SmartFileConfig(...)) β β³ file/image picker
License #
MIT License.