implement static method

NSTextAttachmentContainer implement({
  1. required NSImage? imageForBounds_textContainer_characterIndex_(
    1. CGRect,
    2. NSTextContainer?,
    3. DartNSUInteger
    ),
  2. required CGRect attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex_(
    1. NSTextContainer?,
    2. CGRect,
    3. CGPoint,
    4. DartNSUInteger,
    ),
  3. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSTextAttachmentContainer 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 NSTextAttachmentContainer implement({
  required NSImage? Function(objc.CGRect, NSTextContainer?, DartNSUInteger)
  imageForBounds_textContainer_characterIndex_,
  required objc.CGRect Function(
    NSTextContainer?,
    objc.CGRect,
    objc.CGPoint,
    DartNSUInteger,
  )
  attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(
    debugName: 'NSTextAttachmentContainer',
  );
  NSTextAttachmentContainer.imageForBounds_textContainer_characterIndex_
      .implement(builder, imageForBounds_textContainer_characterIndex_);
  NSTextAttachmentContainer
      .attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex_
      .implement(
        builder,
        attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex_,
      );
  builder.addProtocol($protocol);
  return NSTextAttachmentContainer.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}