getAttachmentByName method

Attachment<Pointer<NativeType>>? getAttachmentByName(
  1. String slotName,
  2. String attachmentName
)

Finds an attachment by looking in the currently set skin (see getSkin) and default skin (see SkeletonData.getDefaultSkin) using the slot name and attachment name.

See getAttachment.

Implementation

Attachment? getAttachmentByName(String slotName, String attachmentName) {
  final slotNameNative = slotName.toNativeUtf8(allocator: _allocator);
  final attachmentNameNative = attachmentName.toNativeUtf8(allocator: _allocator);
  final attachment = _bindings.spine_skeleton_get_attachment_by_name(_skeleton, slotNameNative.cast(), attachmentNameNative.cast());
  _allocator.free(slotNameNative);
  _allocator.free(attachmentNameNative);
  if (attachment.address == nullptr.address) return null;
  return Attachment._toSubclass(attachment);
}