getEnum method

dynamic getEnum({
  1. required String key,
  2. required List values,
  3. dynamic defaultValue,
})

Implementation

dynamic getEnum(
    {required String key,
    required List<dynamic> values,
    dynamic defaultValue}) {
  dynamic data = _data[key];

  if (data == null) {
    return defaultValue;
  }

  if (data is Enum) {
    return data;
  }

  for (dynamic value in values) {
    if (value.toString().split('.').last == data) {
      return value;
    }
  }

  return defaultValue;
}