Skip to content

Make onSelectionChanged of SelectionArea equivalent to that of SelectableText #110594

@kaboc

Description

@kaboc

The onSelectionChanged callback was added to SelectionArea by #108985, but the callback is only given plain text. It is not equivalent to onSelectionChanged of SelectableText.

I asked @chunhtai about this in #108231 (comment), so please refer to the comments starting from there.

Use case

An app that has the feature to highlight a selected piece of text.

When a user selects "pick" in "Peter Piper picked a peck of pickled peppers", there is no way to tell which one of the two "pick"s in the sentence should be highlighted, without necessary info on the selection.

The above is of course just an example. There should be more use cases that require detailed text selection information.

Proposal

The onSelectionChanged callback of SelectableText receives detailed information regarding text selection, like selection offsets. The arguments with the same name in SelectionArea should behave in the same way. It is not because both have the same name, but because I think there must be cases where some functionality that you want to implement in an app cannot be achieved without selection details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.f: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIsframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions