Skip to content

Instantly share code, notes, and snippets.

@yjbanov
Created December 8, 2023 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yjbanov/9274e7d92d7485517a04481fe5d38030 to your computer and use it in GitHub Desktop.
Save yjbanov/9274e7d92d7485517a04481fe5d38030 to your computer and use it in GitHub Desktop.
A sketch for a FlutterView focus API
abstract interface class FlutterView {
FlutterViewFocusState get focusState;
/// The timing of these events relative to keyboard events
/// is such and such.
FlutterViewFocusStateChanged get onFocusStateChanged;
set onFocusStateChanged(FlutterViewFocusStateChanged callback);
}
typedef FlutterViewFocusStateChanged = Function(
FlutterViewFocusStateChangedNotification notification,
);
final class FlutterViewFocusState {
FlutterViewFocusState({
required this.hasFocus,
});
final bool hasFocus;
}
final class FlutterViewFocusStateChangedNotification {
FlutterViewFocusStateChangedNotification({
required this.oldState,
required this.newState,
required this.direction,
});
final FlutterViewFocusState oldState;
final FlutterViewFocusState newState;
final FocusChangeDirection direction;
}
enum FocusChangeDirection {
// TAB
forward,
// Shift TAB
backward,
// Alt+TAB, or focus lost
unknown,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment