Coordinates the animation of the bottom viewport inset in response to system keyboard visibility changes. More...
#include <FlutterKeyboardInsetManager.h>
Instance Methods | |
| (instancetype) | - initWithDelegate: |
| Initializes the manager with a delegate. | |
| (void) | - handleKeyboardNotification: |
| Processes a system keyboard notification to update the target inset and begin any necessary animations. | |
| (void) | - hideKeyboardImmediately |
| Immediately stops any active keyboard animations and synchronizes the engine's viewport metrics with a zero inset. | |
| (void) | - invalidate |
| Terminates any active animations and releases internal resources. | |
Properties | |
| CGFloat | targetViewInsetBottom |
| The physical pixel value of the bottom inset once the current animation reaches its final state. | |
| BOOL | isKeyboardInOrTransitioningFromBackground |
| Indicates whether the keyboard is currently onscreen or in the process of transitioning from the background. | |
Coordinates the animation of the bottom viewport inset in response to system keyboard visibility changes.
This manager translates native iOS keyboard notifications into pixel insets for the engine. It ensures that the Flutter app UI correctly resizes or scrolls when the software keyboard appears or disappears.
We synchronize the app's layout transitions with the native keyboard animation curve by tracking a hidden internal view. When a keyboard notification is received, this view is animated using the native iOS duration and curve. The manager tracks this animation and calls the delegate's update methods on every vsync pulse until the transition completes.
iOS doesn't provide us with a frame-by-frame callback for keyboard transitions, but we need to animate our views smoothly to account for keyboard size/position changes. To ensure Flutter's layout animates in perfect sync with the system keyboard, we use a "hidden view" synchronization trick:
To prevent incorrect layout shifts, the manager filters notifications based on the following criteria:
Definition at line 107 of file FlutterKeyboardInsetManager.h.
| - (void) handleKeyboardNotification: | (NSNotification*) | notification |
Processes a system keyboard notification to update the target inset and begin any necessary animations.
Consider calling this method from the view controller's keyboard notification observers. It automatically performs filtering for non-local or floating keyboard events.
| notification | The notification received from the [NSNotificationCenter]. |
Definition at line 27 of file FlutterKeyboardInsetManager.mm.
References self.
| - (void) hideKeyboardImmediately |
Immediately stops any active keyboard animations and synchronizes the engine's viewport metrics with a zero inset.
Definition at line 27 of file FlutterKeyboardInsetManager.mm.
| - (instancetype) initWithDelegate: | (id<FlutterKeyboardInsetManagerDelegate>) | delegate |
Initializes the manager with a delegate.
The manager maintains a weak reference to the delegate.
| delegate | The object that handles viewport updates. Typically a [FlutterViewController]. |
Definition at line 27 of file FlutterKeyboardInsetManager.mm.
| - (void) invalidate |
Terminates any active animations and releases internal resources.
Consider calling this method when the owner of the manager is being deallocated.
Definition at line 27 of file FlutterKeyboardInsetManager.mm.
|
readwritenonatomicassign |
Indicates whether the keyboard is currently onscreen or in the process of transitioning from the background.
Definition at line 152 of file FlutterKeyboardInsetManager.h.
|
readnonatomicassign |
The physical pixel value of the bottom inset once the current animation reaches its final state.
Definition at line 146 of file FlutterKeyboardInsetManager.h.