mapToStruct function

Map<String, Object?> mapToStruct(
  1. Map<String, Object?> map
)

Converts a plain Dart map to a google.protobuf.Struct JSON map.

Wraps the entries in the canonical {"fields": {...}} envelope, converting each value to a google.protobuf.Value via nativeToValue.

Implementation

Map<String, Object?> mapToStruct(Map<String, Object?> map) {
  final fields = <String, Object?>{};
  for (final entry in map.entries) {
    fields[entry.key] = nativeToValue(entry.value);
  }
  return {'fields': fields};
}