Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Properties | List of all members
FlutterKeyCallbackGuard Class Reference
Inheritance diagram for FlutterKeyCallbackGuard:

Instance Methods

(nonnull instancetype) - initWithCallback:
 
(void) - pendTo:withId:
 
(void) - resolveTo:
 
(nonnull instancetype) - initWithCallback:
 
(void) - pendTo:withId:
 
(void) - resolveTo:
 

Properties

BOOL handled
 
NSString * debugHandleSource
 
BOOL sentAnyEvents
 

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.

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

Method Documentation

◆ initWithCallback: [1/2]

- (nonnull instancetype) initWithCallback: (FlutterAsyncKeyCallback callback
Initial value:
{
void(^ FlutterAsyncKeyCallback)(BOOL handled)

Definition at line 308 of file FlutterEmbedderKeyResponder.mm.

317 self = [super init];
318 if (self != nil) {
319 _callback = [callback copy];
320 _handled = FALSE;
321 }
322 return self;
323}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
return FALSE

◆ initWithCallback: [2/2]

- (nonnull instancetype) initWithCallback: (FlutterAsyncKeyCallback callback

◆ pendTo:withId: [1/2]

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

Handle the callback by storing it to pending responses.

Definition at line 308 of file FlutterEmbedderKeyResponder.mm.

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

◆ pendTo:withId: [2/2]

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

Handle the callback by storing it to pending responses.

◆ resolveTo: [1/2]

- (void) resolveTo: (BOOL handled

Handle the callback by calling it with a result.

Definition at line 308 of file FlutterEmbedderKeyResponder.mm.

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

◆ resolveTo: [2/2]

- (void) resolveTo: (BOOL handled

Handle the callback by calling it with a result.

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

◆ handled

- (BOOL) handled
readwritenonatomicassign

Definition at line 301 of file FlutterEmbedderKeyResponder.mm.

◆ sentAnyEvents

- (BOOL) sentAnyEvents
readwritenonatomicassign

Definition at line 281 of file FlutterEmbedderKeyResponder.mm.


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