Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[SelectableText widget] Jumpy scrolling when doing long press gesture to select text #91464

Closed
@ilovesardine

Description

@ilovesardine

Initial Information

Suppose I have a full-height container with only SelectableText widget inside which will fill the height of container. Inside the widget is a long text (for example 6 paragraphs of Lorem Ipsum) so naturally the widget will be scrollable and some text will be obscured.

Sample code:

class Sample extends StatefulWidget {
  Sample ({Key key}) : super(key: key);

  @override
  _Sample State createState() => _Sample State();
}

class _Sample State extends State<Sample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Container(
          child: SelectableText(
           ...long text here...
          ),
        ),
      ),
    );
  }
}

Steps to Reproduce

CASE 1

  1. After page finishes building, select a word at the beginning of the text by long pressing it.
  2. Cancel selection by tapping anywhere on the text.
  3. Scroll down until the previously selected word gets obscured (In this case, to max scroll offset).
  4. Select a word by again long pressing it.

CASE 2

  1. After page finishes building, scroll down to max scroll offset.
  2. Select a word by long pressing it.
  3. Cancel selection by tapping anywhere on the text.
  4. Scroll up until previously selected word is obscured (In this case, to min scroll offset).
  5. Select a word by again long pressing it.

Expected results:

The word is highlighted.

Actual results:

CASE 1 and CASE 2
The word is highlighted, but;
Widget gets jumpy and scrolls in the direction of where the initially selected word is located on screen.

Additional Info

Issue only happens when I select a word by long-pressing it. This doesn't happen if I double tap on it.
Issue also happens on SelectableText.rich widget.

Logs
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel unknown, 2.5.0, on Microsoft Windows [Version 10.0.18363.1256], locale en-ID)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.60.2)
[√] Connected device (2 available)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: typographyText rendering, possibly libtxtf: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.f: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIsfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions