maxLength static method
Maximum length
Implementation
static String? Function(String?) maxLength(int length, [String? message]) {
return (value) {
if (value == null || value.isEmpty) return null;
if (value.length > length) {
return message ?? 'Must be at most $length characters';
}
return null;
};
}