Skip to content

[ios]Support secure paste for iPad hardware keyboard shortcut (CMD+V) #143999

@hellohuanlin

Description

@hellohuanlin

Problem:

When user type CMD+V, Flutter app shows paste warning, but native app does not show the warning. (related: #103163)

Why flutter apps trigger this warning?

The path is quite complex with multiple steps:

  1. User press CMD+V
  2. iOS calls FlutterTextInputView's key press event handlers
  3. The keyboard event is eventually relayed to FlutterKeyboardManager, which sends to the framework
  4. Framework handles the keyboard event and request access to clipboard from the engine
  5. FlutterPlatformPlugin programmatically access the pasteboard, triggering the paste warning

Why native apps are ok?

As explained in the design doc, iOS has access to private APIs, which contains the secret logic that unlocks the pasteboard content. That logic is probably invoked by the default keyboard handler (which we override).

Solution?

To find out where this logic is, I removed the custom handlers from both FlutterTextInputView and FlutterViewController. By doing so, iOS will just follows the responder chain and eventually use default handlers, which unlocks the pasteboard contents. Then I was able to successfully paste in content using keyboard, without triggering the paste warning.

So problem solved? Not quite!

Removing these custom handlers will probably break framework's KeyboardListener widget. I am not familiar with how keyboard works, so this will need more investigation to properly solve it (if it's solvable). I don't think it's high priority, as it only impact iPad hardware keyboard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: text inputEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions