range static method

String? Function(dynamic) range(
  1. num min,
  2. num max, {
  3. String? message,
})

Implementation

static String? Function(dynamic) range(num min, num max, {String? message}) {
  return (value) {
    if (value == null || value.toString().isEmpty) return null;
    final n = num.tryParse(value.toString());
    if (n == null) return "Invalid number";

    if (n < min || n > max) {
      return (message ?? "Must be between $min and $max");
    }
    return null;
  };
}