Currently there aren't perfect solution for the most common form field.
TextFormField
Works. However formini state resets on hot reload and TextFormField's state doesn't causing the input show previous (mismatching with state) value.
FormControlBuilder(
control: user.email,
builder: (context, state) => TextFormField(
initialValue: state.value,
onChanged: user.email.setValue,
decoration: InputDecoration(
labelText: 'Email address',
errorText: state.dirty ? state.error?.toString() : null,
),
),
)
TextField
Works. However the TextEditingController also controls the cursor state so creating a new control for every value causes the cursor to go to the beginning of the value.
FormControlBuilder(
control: user.email,
builder: (context, state) => TextField(
controller: TextEditingController(text: state.value),
onChanged: user.email.setValue,
decoration: InputDecoration(
labelText: 'Email address',
errorText: state.dirty ? state.error?.toString() : null,
),
),
)
FormEditableTextAdaptor
Works pretty much perfectly once done right. However formini doesn't provide form fields and this widget got too dangerously close to that area thus deleted from the codebase.
https://github.com/vantageoy/formini/blob/21af81ba70c1eebcbdc826ef292fe323850f7b92/lib/src/flutter/adaptors/form_editable_text_adaptor.dart
FormEditableTextAdaptor(
control: user.email,
builder: (context, controller, state) => TextField(
controller: controller,
decoration: InputDecoration(
labelText: 'Email address',
errorText: state.dirty ? state.error?.toString() : null,
),
),
)
Currently there aren't perfect solution for the most common form field.
TextFormField
Works. However formini state resets on hot reload and
TextFormField's state doesn't causing the input show previous (mismatching with state) value.TextField
Works. However the
TextEditingControlleralso controls the cursor state so creating a new control for every value causes the cursor to go to the beginning of the value.FormEditableTextAdaptor
Works pretty much perfectly once done right. However formini doesn't provide form fields and this widget got too dangerously close to that area thus deleted from the codebase.
https://github.com/vantageoy/formini/blob/21af81ba70c1eebcbdc826ef292fe323850f7b92/lib/src/flutter/adaptors/form_editable_text_adaptor.dart