implementAsBlocking static method

NSUserNotificationCenterDelegate implementAsBlocking({
  1. void userNotificationCenter_didDeliverNotification_(
    1. NSUserNotificationCenter,
    2. NSUserNotification
    )?,
  2. void userNotificationCenter_didActivateNotification_(
    1. NSUserNotificationCenter,
    2. NSUserNotification
    )?,
  3. bool userNotificationCenter_shouldPresentNotification_(
    1. NSUserNotificationCenter,
    2. NSUserNotification
    )?,
  4. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSUserNotificationCenterDelegate protocol. To implement multiple protocols, use addToBuilder or objc.ObjCProtocolBuilder directly. All methods that can be implemented as blocking listeners will be.

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

Implementation

static NSUserNotificationCenterDelegate implementAsBlocking({
  void Function(NSUserNotificationCenter, NSUserNotification)?
  userNotificationCenter_didDeliverNotification_,
  void Function(NSUserNotificationCenter, NSUserNotification)?
  userNotificationCenter_didActivateNotification_,
  bool Function(NSUserNotificationCenter, NSUserNotification)?
  userNotificationCenter_shouldPresentNotification_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(
    debugName: 'NSUserNotificationCenterDelegate',
  );
  NSUserNotificationCenterDelegate
      .userNotificationCenter_didDeliverNotification_
      .implementAsBlocking(
        builder,
        userNotificationCenter_didDeliverNotification_,
      );
  NSUserNotificationCenterDelegate
      .userNotificationCenter_didActivateNotification_
      .implementAsBlocking(
        builder,
        userNotificationCenter_didActivateNotification_,
      );
  NSUserNotificationCenterDelegate
      .userNotificationCenter_shouldPresentNotification_
      .implement(builder, userNotificationCenter_shouldPresentNotification_);
  builder.addProtocol($protocol);
  return NSUserNotificationCenterDelegate.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}