toInstantJsonOverrides method
The changed visual properties as InstantJSON-shaped overrides.
Native saveAnnotationProperties implementations overlay these onto the
annotation's existing InstantJSON. Unlike toJson (which uses the model's
own vocabulary — ARGB-int colours, an annotationId key), this emits
valid InstantJSON: colours as "#RRGGBB" hex strings, and no identity
keys (annotationId / pageIndex aren't InstantJSON fields and would be
rejected). Only the visually-editable fields are included; null (untouched)
fields are omitted so unchanged properties are left alone.
Implementation
Map<String, dynamic> toInstantJsonOverrides() => {
if (strokeColor != null) 'strokeColor': _argbToHex(strokeColor!),
if (fillColor != null) 'fillColor': _argbToHex(fillColor!),
if (opacity != null) 'opacity': opacity,
if (lineWidth != null) 'lineWidth': lineWidth,
if (contents != null) 'contents': contents,
// InstantJSON keys flags as a `flags` array of flag-name strings; the
// model stores them as a JSON string, so decode before merging. The
// full set replaces the annotation's flags (callers send the complete
// set), so untouched flags are preserved and cleared ones are removed.
if (_flagsList() != null) 'flags': _flagsList(),
// InstantJSON keys custom data as `customData` (an object); the model
// stores it as a JSON string, so decode before merging. A non-JSON
// string is dropped rather than corrupting the InstantJSON.
if (_customDataObject() != null) 'customData': _customDataObject(),
};