buildFieldMask function

String buildFieldMask(
  1. List<PlaceField> fields, {
  2. String? prefix,
})

Builds the X-Goog-FieldMask header value for a list of inter.PlaceFields.

When prefix is provided (e.g. "places" for search endpoints), each field will be prefixed accordingly: places.id, places.displayName, etc.

Implementation

String buildFieldMask(List<inter.PlaceField> fields, {String? prefix}) {
  final fieldNames = fields.map(placeFieldToApiName).toSet();
  if (prefix != null) {
    return fieldNames.map((f) => '$prefix.$f').join(',');
  }
  return fieldNames.join(',');
}