hcValidateTextField function

bool hcValidateTextField(
  1. BuildContext context,
  2. dynamic controller,
  3. String fieldName, {
  4. FocusNode? focusNode,
})

Validate Text Field or Dropdown Value

Implementation

bool hcValidateTextField(BuildContext context, var controller, String fieldName,
    {FocusNode? focusNode}) {
  if (controller.isEmpty) {
    if (focusNode != null) {
      focusNode.requestFocus();
    }
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
      content: Text('$fieldName can\'t be empty'),
    ));
    return false;
  }
  return true;
}