| Flutter macOS Embedder |

Instance Methods | Properties | List of all members
FlutterKeyCallbackGuard Class Reference
Inheritance diagram for FlutterKeyCallbackGuard:

## Instance Methods
(nonnull instancetype) | - initWithCallback:
(void) | - pendTo:withId:
(void) | - resolveTo:

## Properties
BOOL | handled
BOOL | sentAnyEvents
NSString * | debugHandleSource

## Detailed Description

Guards a |FlutterAsyncKeyCallback| to make sure it's handled exactly once throughout |FlutterEmbedderKeyResponder.handleEvent|.

A callback can either be handled with |pendTo:withId:|, or with |resolveTo:|. Either way, the callback cannot be handled again, or an assertion will be thrown.

Definition at line 266 of file FlutterEmbedderKeyResponder.mm.

## Method Documentation

## ◆ initWithCallback:

- (nonnull instancetype) initWithCallback: |  | (FlutterAsyncKeyCallback) | callback |

Initial value:
{
FlutterAsyncKeyCallback _callback

Definition at line 296 of file FlutterEmbedderKeyResponder.mm.

296 :(FlutterAsyncKeyCallback)callback {
297 self = [super init];
298 if (self != nil) {
299 _callback = callback;
300 _handled = FALSE;
301 _sentAnyEvents = FALSE;
302 }
303 return self;
304 }

## ◆ pendTo:withId:

- (void) pendTo: |  | (nonnull NSMutableDictionary<NSNumber*, FlutterAsyncKeyCallback>*) | pendingResponses
withId: |  | (uint64_t) | responseId

Handle the callback by storing it to pending responses.

Definition at line 306 of file FlutterEmbedderKeyResponder.mm.

306 :(nonnull NSMutableDictionary<NSNumber*, FlutterAsyncKeyCallback>*)pendingResponses
307 withId:(uint64_t)responseId {
308 NSAssert(!_handled, @"This callback has been handled by %@.", _debugHandleSource);
309 if (_handled) {
310 return;
311 }
312 pendingResponses[@(responseId)] = _callback;
313 _handled = TRUE;
314 NSAssert(
315 ((_debugHandleSource = [NSString stringWithFormat:@"pending event %llu", responseId]), TRUE),
316 @"");
317 }

## ◆ resolveTo:

- (void) resolveTo: |  | (BOOL) | handled |

Handle the callback by calling it with a result.

Definition at line 319 of file FlutterEmbedderKeyResponder.mm.

319 :(BOOL)handled {
320 NSAssert(!_handled, @"This callback has been handled by %@.", _debugHandleSource);
321 if (_handled) {
322 return;
323 }
324 _callback(handled);
325 _handled = TRUE;
326 NSAssert(((_debugHandleSource = [NSString stringWithFormat:@"resolved with %d", _handled]), TRUE),
327 @"");
328 }

## Property Documentation

## ◆ debugHandleSource

- (NSString*) debugHandleSource
| read write nonatomic copy

A string indicating how the callback is handled.

Only set in debug mode. Nil in release mode, or if the callback has not been handled.

Definition at line 288 of file FlutterEmbedderKeyResponder.mm.

## ◆ handled

- (BOOL) handled
| read write nonatomic assign

Definition at line 280 of file FlutterEmbedderKeyResponder.mm.

## ◆ sentAnyEvents

- (BOOL) sentAnyEvents
| read write nonatomic assign

Definition at line 281 of file FlutterEmbedderKeyResponder.mm.

The documentation for this class was generated from the following file:

- shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.mm

FlutterKeyCallbackGuard::handled
BOOL handled
Definition: FlutterEmbedderKeyResponder.mm:280
FlutterAsyncKeyCallback
void(^ FlutterAsyncKeyCallback)(BOOL handled)
Definition: FlutterKeyPrimaryResponder.h:10