requestFocus method

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.requestFocus', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#requestFocus(int,%20android.graphics.Rect)'), IOSPlatform(apiName: 'UIResponder.becomeFirstResponder', apiUrl: 'https://developer.apple.com/documentation/uikit/uiresponder/1621113-becomefirstresponder'), MacOSPlatform(apiName: 'NSWindow.makeFirstResponder', apiUrl: 'https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder'), LinuxPlatform(apiName: 'wpe_view_backend_add_activity_state', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-platform-2.0/func.view_backend_add_activity_state.html', note: 'Adds focused state to WPE backend')])
Future<bool?> requestFocus({
  1. @SupportedPlatforms.new(platforms: [AndroidPlatform()]) FocusDirection? direction,
  2. @SupportedPlatforms.new(platforms: [AndroidPlatform()]) InAppWebViewRect? previouslyFocusedRect,
})
inherited

Call this method when you want to try the WebView to be the first responder.

On Android, call this to try to give focus to the WebView and give it hints about the direction and a specific previouslyFocusedRect that the focus is coming from. The previouslyFocusedRect can help give larger views a finer grained hint about where focus is coming from, and therefore, where to show selection, or forward focus change internally.

Returns true whether this WebView actually took focus; otherwise, false.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'WebView.requestFocus',
      apiUrl:
          'https://developer.android.com/reference/android/webkit/WebView#requestFocus(int,%20android.graphics.Rect)',
    ),
    IOSPlatform(
      apiName: 'UIResponder.becomeFirstResponder',
      apiUrl:
          'https://developer.apple.com/documentation/uikit/uiresponder/1621113-becomefirstresponder',
    ),
    MacOSPlatform(
      apiName: 'NSWindow.makeFirstResponder',
      apiUrl:
          'https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder',
    ),
    LinuxPlatform(
      apiName: 'wpe_view_backend_add_activity_state',
      apiUrl:
          'https://wpewebkit.org/reference/stable/wpe-platform-2.0/func.view_backend_add_activity_state.html',
      note: 'Adds focused state to WPE backend',
    ),
  ],
)
Future<bool?> requestFocus({
  @SupportedPlatforms(platforms: [AndroidPlatform()])
  FocusDirection? direction,
  @SupportedPlatforms(platforms: [AndroidPlatform()])
  InAppWebViewRect? previouslyFocusedRect,
}) {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.requestFocus.name} is not implemented on the current platform',
  );
}