required static method

String? required(
  1. String? value, {
  2. String? fieldName,
})

Validate required field

Implementation

static String? required(String? value, {String? fieldName}) {
  if (value == null || value.trim().isEmpty) {
    return '${fieldName ?? 'This field'} is required';
  }
  return null;
}