IInstanceExtension
PIComposer APIPIComposer API

IInstanceExtension#

extension IInstanceExtension on IInstance

Extension on the IInstance interface providing convenient utility functions.

Methods#

setGuid() extension#

bool setGuid({ String? attName, int? attIndex})

Sets a string attribute to a newly generated GUID value.

Either attName or attIndex must be provided to identify the target attribute.

attName: The name of the attribute to set. attIndex: The index of the attribute to set.

Returns true if the attribute was successfully set with a new GUID, false if the attribute could not be found or accessed.

Available on IInstance, provided by the IInstanceExtension extension

Implementation
bool setGuid({String? attName, int? attIndex}) {
  final index = attIndex ?? getAttributeIndex(attName ?? '');
  if (index < 0) {
    return false;
  }
  setAttribute(attIndex: index, PIComposerAPIFFI.getGuid());
  return true;
}