stripProtoFields<V> function

Map<String, V> stripProtoFields<V>(
  1. Map<String, V> metadata
)

Strip _PROTO_* keys from a payload destined for general-access storage. Returns the input unchanged when no PROTO keys present.

Implementation

Map<String, V> stripProtoFields<V>(Map<String, V> metadata) {
  final hasProto = metadata.keys.any((k) => k.startsWith('_PROTO_'));
  if (!hasProto) return metadata;
  return Map<String, V>.fromEntries(
    metadata.entries.where((e) => !e.key.startsWith('_PROTO_')),
  );
}