hcValidateTextInputField function
bool
hcValidateTextInputField(
- BuildContext context,
- TextEditingController controller,
- String fieldName, {
- FocusNode? focusNode,
Validate Text Input Field
Implementation
bool hcValidateTextInputField(
BuildContext context, TextEditingController controller, String fieldName,
{FocusNode? focusNode}) {
if (controller.text.isEmpty) {
if (focusNode != null) {
focusNode.requestFocus();
}
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('$fieldName can\'t be empty'),
));
return false;
}
return true;
}