implementAsBlocking static method

NSSpeechSynthesizerDelegate implementAsBlocking({
  1. void speechSynthesizer_didFinishSpeaking_(
    1. NSSpeechSynthesizer,
    2. bool
    )?,
  2. void speechSynthesizer_willSpeakWord_ofString_(
    1. NSSpeechSynthesizer,
    2. NSRange,
    3. NSString
    )?,
  3. void speechSynthesizer_willSpeakPhoneme_(
    1. NSSpeechSynthesizer,
    2. int
    )?,
  4. void speechSynthesizer_didEncounterErrorAtIndex_ofString_message_(
    1. NSSpeechSynthesizer,
    2. DartNSUInteger,
    3. NSString,
    4. NSString,
    )?,
  5. void speechSynthesizer_didEncounterSyncMessage_(
    1. NSSpeechSynthesizer,
    2. NSString
    )?,
  6. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSSpeechSynthesizerDelegate 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 NSSpeechSynthesizerDelegate implementAsBlocking({
  void Function(NSSpeechSynthesizer, bool)?
  speechSynthesizer_didFinishSpeaking_,
  void Function(NSSpeechSynthesizer, NSRange, objc.NSString)?
  speechSynthesizer_willSpeakWord_ofString_,
  void Function(NSSpeechSynthesizer, int)?
  speechSynthesizer_willSpeakPhoneme_,
  void Function(
    NSSpeechSynthesizer,
    DartNSUInteger,
    objc.NSString,
    objc.NSString,
  )?
  speechSynthesizer_didEncounterErrorAtIndex_ofString_message_,
  void Function(NSSpeechSynthesizer, objc.NSString)?
  speechSynthesizer_didEncounterSyncMessage_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(
    debugName: 'NSSpeechSynthesizerDelegate',
  );
  NSSpeechSynthesizerDelegate.speechSynthesizer_didFinishSpeaking_
      .implementAsBlocking(builder, speechSynthesizer_didFinishSpeaking_);
  NSSpeechSynthesizerDelegate.speechSynthesizer_willSpeakWord_ofString_
      .implementAsBlocking(
        builder,
        speechSynthesizer_willSpeakWord_ofString_,
      );
  NSSpeechSynthesizerDelegate.speechSynthesizer_willSpeakPhoneme_
      .implementAsBlocking(builder, speechSynthesizer_willSpeakPhoneme_);
  NSSpeechSynthesizerDelegate
      .speechSynthesizer_didEncounterErrorAtIndex_ofString_message_
      .implementAsBlocking(
        builder,
        speechSynthesizer_didEncounterErrorAtIndex_ofString_message_,
      );
  NSSpeechSynthesizerDelegate.speechSynthesizer_didEncounterSyncMessage_
      .implementAsBlocking(
        builder,
        speechSynthesizer_didEncounterSyncMessage_,
      );
  builder.addProtocol($protocol);
  return NSSpeechSynthesizerDelegate.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}