implement static method

NSPasteboardItemDataProvider implement({
  1. required void pasteboard_item_provideDataForType_(
    1. NSPasteboard?,
    2. NSPasteboardItem,
    3. DartNSPasteboardType
    ),
  2. void pasteboardFinishedWithDataProvider_(
    1. NSPasteboard
    )?,
  3. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSPasteboardItemDataProvider 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 NSPasteboardItemDataProvider implement({
  required void Function(
    NSPasteboard?,
    NSPasteboardItem,
    DartNSPasteboardType,
  )
  pasteboard_item_provideDataForType_,
  void Function(NSPasteboard)? pasteboardFinishedWithDataProvider_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(
    debugName: 'NSPasteboardItemDataProvider',
  );
  NSPasteboardItemDataProvider.pasteboard_item_provideDataForType_.implement(
    builder,
    pasteboard_item_provideDataForType_,
  );
  NSPasteboardItemDataProvider.pasteboardFinishedWithDataProvider_.implement(
    builder,
    pasteboardFinishedWithDataProvider_,
  );
  builder.addProtocol($protocol);
  return NSPasteboardItemDataProvider.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}