inList static method

String? inList(
  1. String? checkValue,
  2. List<String> list, {
  3. String? errorMessage,
})

Checks if checkValue is in the provided list

If checkValue is not in the provided list than errorMessage will be returned if provided, else the default message is returned. Othersie null is returned

Implementation

static String? inList(String? checkValue, List<String> list,
    {String? errorMessage}) {
  return list.contains(checkValue)
      ? null
      : (errorMessage ?? "Unexpected value");
}