Flutter macOS Embedder
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 267 of file FlutterEmbedderKeyResponder.mm.

Method Documentation

◆ initWithCallback:

- (nonnull instancetype) initWithCallback: (FlutterAsyncKeyCallback callback
Initial value:

Definition at line 297 of file FlutterEmbedderKeyResponder.mm.

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

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

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

◆ resolveTo:

- (void) resolveTo: (BOOL)  handled

Handle the callback by calling it with a result.

Definition at line 320 of file FlutterEmbedderKeyResponder.mm.

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

Property Documentation

◆ debugHandleSource

- (NSString*) debugHandleSource
readwritenonatomiccopy

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

◆ handled

- (BOOL) handled
readwritenonatomicassign

Definition at line 281 of file FlutterEmbedderKeyResponder.mm.

◆ sentAnyEvents

- (BOOL) sentAnyEvents
readwritenonatomicassign

Definition at line 282 of file FlutterEmbedderKeyResponder.mm.


The documentation for this class was generated from the following file:
FlutterKeyCallbackGuard::handled
BOOL handled
Definition: FlutterEmbedderKeyResponder.mm:281
FlutterAsyncKeyCallback
void(^ FlutterAsyncKeyCallback)(BOOL handled)
Definition: FlutterKeyPrimaryResponder.h:10