minLength method Null safety

Validator minLength(
  1. int length,
  2. {bool trim = false,
  3. String message = "Validator.minLength"}
)

Returns a Validator that accepts a value that is longer or of equal length to length.

If the value is null, its length is treated as zero.

If trim is true leading and trailing spaces will be ignored.

Implementation

Validator minLength(
  int length, {
  bool trim = false,
  String message = "Validator.minLength",
}) {
  return add(
    (value) {
      var v = trim ? (value ?? "").trim() : (value ?? "");
      return v.length < length ? message : null;
    },
  );
}