match_variant<T> function

T match_variant<T>(
  1. Variant variant,
  2. Map<String, T Function(CandidType)> match_map
)

Implementation

T match_variant<T>(Variant variant, Map<String, T Function(CandidType)> match_map) {
    for (String variant_string in match_map.keys) {
        CandidType? variant_value = variant[variant_string];
        if (variant_value != null) {
            return match_map[variant_string]!(variant_value);
        }
    }
    throw MatchVariantUnknown<T>(
        variant: variant,
        match_map: match_map
    );
}