NotEmptyValidator function

TextValidator NotEmptyValidator({
  1. bool trim = true,
  2. String message = "不可为空",
})

Implementation

TextValidator NotEmptyValidator({bool trim = true, String message = "不可为空"}) {
  String? validator(String? text) {
    String? s = trim ? text?.trim() : text;
    if (s == null || s.isEmpty) return message;
    return null;
  }

  return validator;
}