deserializeMetadata method

Map<String, dynamic> deserializeMetadata(
  1. Map<String, dynamic>? metadata, {
  2. dynamic covert(
    1. String key,
    2. dynamic value
    )?,
  3. List<NamedAttribution>? customNameAttribution,
})

Deserialized Metadata, which encapsulates common types. Custom metadata needs to be converted by covert.

Implementation

Map<String, dynamic> deserializeMetadata(Map<String, dynamic>? metadata,
    {dynamic Function(String key, dynamic value)? covert,
    List<NamedAttribution>? customNameAttribution}) {
  return metadata?.map((key, value) {
        var covertValue = covert?.call(key, value);
        if (covertValue != null) {
          return MapEntry(key, covertValue);
        }
        if (key == "singleColumnLayout" && value != null) {
          return MapEntry(key, deserializeSingleColumnLayoutMetadata(value));
        }
        final nameAttrs = [
          ...?customNameAttribution,
          ..._allNameAttribution,
        ];
        for (var nameAttr in nameAttrs) {
          if (nameAttr.id == value) {
            return MapEntry(key, NamedAttribution(value));
          }
        }
        return MapEntry(key, value);
      }) ??
      {};
}