serializeMetadata method

Map<String, dynamic> serializeMetadata(
  1. Map<String, dynamic>? metadata, {
  2. dynamic covert(
    1. String key,
    2. dynamic value
    )?,
})

Serializing metadata, which encapsulates generic data transformations. Custom metadata needs to be converted via the covert callback method.

Implementation

Map<String, dynamic> serializeMetadata(Map<String, dynamic>? metadata,
    {dynamic Function(String key, dynamic value)? covert}) {
  return metadata?.map((key, value) {
        var covertValue = covert?.call(key, value);
        if (covertValue != null) {
          return MapEntry(key, covertValue);
        }
        if (value is Attribution) {}
        if (value is NamedAttribution) {
          return MapEntry(key, value.id);
        }
        if (key == "singleColumnLayout" && value != null) {
          return MapEntry(key, serializeSingleColumnLayoutMetadata(value));
        }
        return MapEntry(key, value?.toString());
      }) ??
      {};
}