isValidValue<T> static method
Returns true
if the the given value
is found within validValues
or
if the validValues
list is empty and value
is empty as well.
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);
}