implement static method

NSTextAttachmentLayout implement({
  1. required NSImage? imageForBounds_attributes_location_textContainer_(
    1. CGRect,
    2. NSDictionary,
    3. NSTextLocation,
    4. NSTextContainer?,
    ),
  2. required CGRect attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position_(
    1. NSDictionary,
    2. NSTextLocation,
    3. NSTextContainer?,
    4. CGRect,
    5. CGPoint,
    ),
  3. required NSTextAttachmentViewProvider? viewProviderForParentView_location_textContainer_(
    1. NSView?,
    2. NSTextLocation,
    3. NSTextContainer?
    ),
  4. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSTextAttachmentLayout protocol. To implement multiple protocols, use addToBuilder or objc.ObjCProtocolBuilder directly.

If $keepIsolateAlive is true, this protocol will keep this isolate alive until it is garbage collected by both Dart and ObjC.

Implementation

static NSTextAttachmentLayout implement({
  required NSImage? Function(
    objc.CGRect,
    objc.NSDictionary,
    NSTextLocation,
    NSTextContainer?,
  )
  imageForBounds_attributes_location_textContainer_,
  required objc.CGRect Function(
    objc.NSDictionary,
    NSTextLocation,
    NSTextContainer?,
    objc.CGRect,
    objc.CGPoint,
  )
  attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position_,
  required NSTextAttachmentViewProvider? Function(
    NSView?,
    NSTextLocation,
    NSTextContainer?,
  )
  viewProviderForParentView_location_textContainer_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(
    debugName: 'NSTextAttachmentLayout',
  );
  NSTextAttachmentLayout.imageForBounds_attributes_location_textContainer_
      .implement(builder, imageForBounds_attributes_location_textContainer_);
  NSTextAttachmentLayout
      .attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position_
      .implement(
        builder,
        attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position_,
      );
  NSTextAttachmentLayout.viewProviderForParentView_location_textContainer_
      .implement(builder, viewProviderForParentView_location_textContainer_);
  builder.addProtocol($protocol);
  return NSTextAttachmentLayout.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}