getAttachment method

Attachment<Pointer<NativeType>>? getAttachment(
  1. int slotIndex,
  2. String attachmentName
)

Finds an attachment by looking in the currently set skin (see getSkin) and default skin (see SkeletonData.getDefaultSkin) using the slot index and attachment name. First the skin is checked and if the attachment was not found, the default skin is checked.

See Runtime skins in the Spine Runtimes Guide.

Implementation

Attachment? getAttachment(int slotIndex, String attachmentName) {
  final attachmentNameNative = attachmentName.toNativeUtf8(allocator: _allocator);
  final attachment = _bindings.spine_skeleton_get_attachment(_skeleton, slotIndex, attachmentNameNative.cast());
  _allocator.free(attachmentNameNative);
  if (attachment.address == nullptr.address) return null;
  return Attachment._toSubclass(attachment);
}