required static method

String? required(
  1. String? value, {
  2. String fieldName = 'This field',
})

Validates that the field is not empty.

Implementation

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