mapToStruct function
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};
}