Skip to content

SelectionArea doesn't seem to work with RichText Widget #174930

Description

@catsclaw

Steps to reproduce

The following code is mostly taken from the example in the RichText documentation, and looks to me like it should allow selection of the RichText region. It doesn't. Replacing it with the Text span works.

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      builder: (context, child) => child!,
      home: Scaffold(
        body: SelectionArea(
          // child: Text('Select!'),
          child: RichText(
            text: const TextSpan(text: 'Hello', style: TextStyle(color: Colors.black)),
            selectionRegistrar: SelectionContainer.maybeOf(context),
            selectionColor: const Color(0xAF6694e8),
          ),
        ),
      ),
    );
  }
}

Actual results

The text remains unselectable.

Logs

No response

Flutter Doctor output

Doctor output
    6.12.10-76061203-generic, locale en_US.UTF-8) [285ms]
    • Flutter version 3.35.2 on channel stable at
      /home/chris/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 05db968908 (10 days ago), 2025-08-25 10:21:35 -0700
    • Engine revision a8bfdfc394
    • Dart version 3.9.0
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
      enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [13.5s]
    • Android SDK at /home/chris/Android/Sdk/
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • ANDROID_HOME = /home/chris/Android/Sdk/
    • Java binary at:
      /home/chris/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/jav
      a
      This is the JDK bundled with the latest Android Studio installation on
      this machine.
      To manually set the JDK path, use: `flutter config
      --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
    • All Android licenses accepted.

[✓] Chrome - develop for the web [110ms]
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop [3.3s]
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1
    • GL_EXT_framebuffer_blit: no
    • GL_EXT_texture_format_BGRA8888: no

[✓] Android Studio (version 2025.1.2) [90ms]
    • Android Studio at
      /home/chris/.local/share/JetBrains/Toolbox/apps/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)

[✓] Connected device (2 available) [876ms]
    • Linux (desktop) • linux  • linux-x64      • Pop!_OS 22.04 LTS
      6.12.10-76061203-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 138.0.7204.92

[✓] Network resources [776ms]
    • All expected network resources are available.


Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectd: examplesSample code and demosf: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIsfound in release: 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions