Skip to content

Instantly share code, notes, and snippets.

@umuieme
Last active October 30, 2021 19:41
Show Gist options
  • Select an option

  • Save umuieme/7c34aae6cb00eabb4063387fc9f04f80 to your computer and use it in GitHub Desktop.

Select an option

Save umuieme/7c34aae6cb00eabb4063387fc9f04f80 to your computer and use it in GitHub Desktop.
FormField<String>(
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) =>
(value?.isNotEmpty ?? false) ? null : "Cannot be null",
onSaved: (value)=> customName = value,
builder: (state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: TextFormField(
decoration: const InputDecoration(
hintText: "Custom Name"),
onChanged: (value) => state.didChange(value),
),
),
if (state.isValid) const Icon(Icons.check),
if (state.hasError)
const Icon(
Icons.close,
color: Colors.red,
),
],
),
if (state.hasError)
Text(
state.errorText ?? "",
style: const TextStyle(color: Colors.red),
)
],
);
},
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment