setField method

void setField({
  1. required int index,
  2. required ContactInfoFieldType type,
  3. required String value,
  4. required String name,
})

Sets or updates a contact field at index.

If index is negative the call does nothing. If index is within the current range the field is updated; when index is beyond the current field count a new field is appended (behavior mirrors the native API).

Parameters

  • index: Index of the field to set or update.
  • type: The field type to store.
  • value: The field value to store.
  • name: Display name for the field.

Implementation

void setField({
  required final int index,
  required final ContactInfoFieldType type,
  required final String value,
  required final String name,
}) {
  if (index < 0) {
    return;
  }
  if (index < fieldsCount) {
    objectMethod(
      pointerId,
      'ContactInfo',
      'setField',
      args: <String, dynamic>{
        'index': index,
        'type': type.id,
        'value': value,
        'name': name,
      },
    );
  } else {
    addField(type: type, value: value, name: name);
  }
}