Skip to content

TapRegion has no clear way to differentiate between different gestures #140271

@Hannnes1

Description

@Hannnes1

Use case

By default, the on screen keyboard is dismissed by non-mobile touch events, such as a click.
It is quite common to want similar behavior on mobile. That can be done by calling unfocus on the text fields FocusNode inside the onTapCallback. That does however mean that both taps and scrolls are handled the same, since TapRegion uses PointerDownEvent as a trigger for onTapOutside. (Contradictory to what the name might suggest. Compare with onTap and onTapDown in GestureDetector)

Having the ability to differentiate between scroll and tap would give developers the ability to close the text field on a tap, but keep it open when scrolling.

Attached below is a video of the Google Home app on Android, showing the behavior that I'm looking for.

untitled.mp4

Proposal

TapRegion, should have more parameters to differentiate between different gestures, similar to GestureDetector. This would be a breaking change, but onTapOutside should behave like onTap of GestureDetector, and a new parameter with the name onTapDownOutside should be added that has the current behaviour. Other gestures should be handled by other parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions