isValidValue<T> static method
Returns true if value is found within validValues or is an empty
string or iterable. Returns false for null.
Implementation
static bool isValidValue<T>(T value, List<T> validValues) {
if (value == null) return false;
// Let empty values pass.
if (value is String) {
if (value.isEmpty) return true;
} else if (value is Iterable) {
if (value.isEmpty) return true;
}
return validValues.contains(value);
}