onViewFocusChange property

  1. @override
ViewFocusChangeCallback? onViewFocusChange
override

A callback invoked immediately after the focus is transitioned across FlutterViews.

When the platform moves the focus from one FlutterView to another, this callback is invoked indicating the new view that has focus and the direction in which focus was received. For example, if focus is moved to the FlutterView with ID 2 in the forward direction (could be the result of pressing tab) the callback receives a ViewFocusEvent with ViewFocusState.focused and ViewFocusDirection.forward.

Typically, receivers of this event respond by moving the focus to the first focusable widget inside the FlutterView with ID 2. If a view receives focus in the backward direction (could be the result of pressing shift + tab), typically the last focusable widget inside that view is focused.

The platform may remove focus from a FlutterView. For example, on the web, the browser can move focus to another element, or to the browser's built-in UI. On desktop, the operating system can switch to another window (e.g. using Alt + Tab on Windows). In scenarios like these, onViewFocusChange will be invoked with ViewFocusState.unfocused and ViewFocusDirection.undefined.

Receivers typically respond to this event by removing all focus indications from the app.

Apps can also programmatically request to move the focus to a desired FlutterView by calling requestViewFocusChange.

The callback is invoked in the same zone in which the callback was set.

See also:

Implementation

@override
ViewFocusChangeCallback? get onViewFocusChange => _platformDispatcher.onViewFocusChange;
  1. @override
void onViewFocusChange=(ViewFocusChangeCallback? callback)
override

Implementation

@override
set onViewFocusChange(ViewFocusChangeCallback? callback) {
  _onViewFocusChange = callback;
}