fromJson<T extends Enum> static method

Label<T> fromJson<T extends Enum>(
  1. Map json,
  2. List<T> values,
  3. T defaultValue
)

Creates a Label from a JSON map.

json - The JSON map containing 'label' and optionally 'customLabel'. values - The list of enum values to decode the label from. defaultValue - The default enum value to use if decoding fails.

Implementation

static Label<T> fromJson<T extends Enum>(
  Map json,
  List<T> values,
  T defaultValue,
) {
  return Label<T>(
    JsonHelpers.decodeEnum(json['label'], values, defaultValue),
    json['customLabel'] as String?,
  );
}