| Flutter iOS 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
NSString * | debugHandleSource

## Detailed Description

Guards a |FlutterAsyncKeyCallback| to make sure it's handled exactly once throughout the process of handling an event in |FlutterEmbedderKeyResponder|.

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 284 of file FlutterEmbedderKeyResponder.mm.

## Method Documentation

## ◆ initWithCallback:

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

Initial value:
{
FlutterAsyncKeyCallback _callback

Definition at line 313 of file FlutterEmbedderKeyResponder.mm.

313 :(FlutterAsyncKeyCallback)callback {
314 self = [super init];
315 if (self != nil) {
316 _callback = [callback copy];
317 _handled = FALSE;
318 }
319 return self;
320 }

## ◆ 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 327 of file FlutterEmbedderKeyResponder.mm.

327 :(nonnull NSMutableDictionary<NSNumber*, FlutterAsyncKeyCallback>*)pendingResponses
328 withId:(uint64_t)responseId {
329 NSAssert(!_handled, @"This callback has been handled by %@.", _debugHandleSource);
330 if (_handled) {
331 return;
332 }
333 pendingResponses[@(responseId)] = _callback;
334 _handled = TRUE;
335 NSAssert(
336 ((_debugHandleSource = [NSString stringWithFormat:@"pending event %llu", responseId]), TRUE),
337 @"");
338 }

## ◆ resolveTo:

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

Handle the callback by calling it with a result.

Definition at line 340 of file FlutterEmbedderKeyResponder.mm.

340 :(BOOL)handled {
341 NSAssert(!_handled, @"This callback has been handled by %@.", _debugHandleSource);
342 if (_handled) {
343 return;
344 }
345 _callback(handled);
346 _handled = TRUE;
347 NSAssert(((_debugHandleSource = [NSString stringWithFormat:@"resolved with %d", _handled]), TRUE),
348 @"");
349 }

## Property Documentation

## ◆ debugHandleSource

- (NSString*) debugHandleSource
| read atomic assign

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 305 of file FlutterEmbedderKeyResponder.mm.

## ◆ handled

- (BOOL) handled
| read write nonatomic assign

Definition at line 298 of file FlutterEmbedderKeyResponder.mm.

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

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

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