Skip to content

Clarify RichText selection docs#186844

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
mvincentong:docs-richtext-selection-context
Jun 12, 2026
Merged

Clarify RichText selection docs#186844
auto-submit[bot] merged 1 commit into
flutter:masterfrom
mvincentong:docs-richtext-selection-context

Conversation

@mvincentong

Copy link
Copy Markdown
Contributor

Fixes #174930.

This updates the RichText selection docs to call out that the context passed to SelectionContainer.maybeOf must be below the SelectionArea or SelectableRegion that provides the selection registrar. The sample now wraps the RichText in a Builder inside the SelectionArea, matching the working pattern from the issue discussion.

It also adjusts the SelectableRegion overview so it says the region enables selection for widgets that participate in selection, rather than implying every child widget becomes selectable automatically.

Tests

  • ./bin/dart format --output=none --set-exit-if-changed packages/flutter/lib/src/widgets/basic.dart packages/flutter/lib/src/widgets/selectable_region.dart
  • ./bin/flutter analyze packages/flutter/lib/src/widgets/basic.dart packages/flutter/lib/src/widgets/selectable_region.dart
  • ./bin/dart --enable-asserts dev/bots/analyze_snippet_code.dart packages/flutter/lib/src/widgets
  • git diff --check

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label May 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for RichText and SelectableRegion to clarify that SelectionContainer.maybeOf requires a BuildContext located below the selection provider in the widget tree, including an updated code example using a Builder. Feedback was provided to ensure consistent terminology and proper class linking for SelectionArea to align with standard Flutter documentation patterns.

Comment thread packages/flutter/lib/src/widgets/basic.dart Outdated
Comment thread packages/flutter/lib/src/widgets/selectable_region.dart Outdated
@mvincentong mvincentong force-pushed the docs-richtext-selection-context branch from 38a7b3f to 7965c95 Compare May 21, 2026 04:20
@Piinks Piinks added a: text input Entering text in a text field or keyboard related problems f: selection SelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIs labels May 26, 2026
@Renzo-Olivares Renzo-Olivares requested a review from Piinks May 28, 2026 20:51

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, thank you!

@Piinks Piinks force-pushed the docs-richtext-selection-context branch from 7965c95 to e7e8f94 Compare June 12, 2026 00:01
@github-actions github-actions Bot removed the a: text input Entering text in a text field or keyboard related problems label Jun 12, 2026
@Piinks Piinks added a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD labels Jun 12, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 12, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jun 12, 2026
Merged via the queue into flutter:master with commit 764a079 Jun 12, 2026
99 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 12, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 12, 2026
flutter/flutter@8bdce07...b7cb925

2026-06-12 engine-flutter-autoroll@skia.org Roll Skia from cadbde1ec4b7 to 8c89bf2b0ee3 (5 revisions) (flutter/flutter#187926)
2026-06-12 engine-flutter-autoroll@skia.org Roll Packages from 1b56cde to b78ad83 (5 revisions) (flutter/flutter#187928)
2026-06-12 engine-flutter-autoroll@skia.org Roll Dart SDK from f3441f2067ae to f6c31f4c3a63 (17 revisions) (flutter/flutter#187924)
2026-06-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 2KosSR4ONUjIB7tP_... to A3eaUn9mQ_EkSNxVI... (flutter/flutter#187923)
2026-06-12 engine-flutter-autoroll@skia.org Roll Skia from a2228b926c68 to cadbde1ec4b7 (9 revisions) (flutter/flutter#187921)
2026-06-12 kustermann@google.com Remove dynamic module loading code in flutter web engine (flutter/flutter#187777)
2026-06-12 matt.kosarek@canonical.com Remove EnableTransparentWindowBackground because it did nothing important and because Windows 10 does not support DWMWA_SYSTEMBACKDROP_TYPE (flutter/flutter#187848)
2026-06-12 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from dQ4PjIJB5kZFU8Y32... to EmfiOMUge_nnNS33B... (flutter/flutter#187912)
2026-06-12 mvincentong@gmail.com Clarify RichText selection docs (flutter/flutter#186844)
2026-06-12 1063596+reidbaker@users.noreply.github.com Custom KGP task and migration to AGP api for geting kgp version (flutter/flutter#182788)
2026-06-12 engine-flutter-autoroll@skia.org Roll Skia from f61acb31edf8 to a2228b926c68 (5 revisions) (flutter/flutter#187896)
2026-06-12 bdero@google.com [Flutter GPU] Expose ASTC HDR texture formats (flutter/flutter#187715)
2026-06-12 awolff@google.com Expand coverage of android_hardware_smoke_test. Add image, text, blend mode, and blur tests. (flutter/flutter#187600)
2026-06-11 bdero@google.com [Flutter GPU] Add blit operations (flutter/flutter#187289)
2026-06-11 bkonyi@google.com [flutter_tools] Fix version cache git fallback performance regression (flutter/flutter#187400)
2026-06-11 nshahan@google.com Rewrite `-d web-server` hot reload/restart tests (flutter/flutter#187453)
2026-06-11 bdero@google.com [Impeller] Allow sampling textures with manually-uploaded mip levels (flutter/flutter#187729)
2026-06-11 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#187884)
2026-06-11 47866232+chunhtai@users.noreply.github.com iOS a11y sets header trait based on heading level (flutter/flutter#186916)
2026-06-11 engine-flutter-autoroll@skia.org Roll Skia from 9f02102df298 to f61acb31edf8 (19 revisions) (flutter/flutter#187869)
2026-06-11 engine-flutter-autoroll@skia.org Roll ICU from ee5f27adc28b to d578f2e8b7bd (8 revisions) (flutter/flutter#187829)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC louisehsu@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
Fixes flutter#174930.

This updates the RichText selection docs to call out that the context
passed to `SelectionContainer.maybeOf` must be below the `SelectionArea`
or `SelectableRegion` that provides the selection registrar. The sample
now wraps the `RichText` in a `Builder` inside the `SelectionArea`,
matching the working pattern from the issue discussion.

It also adjusts the `SelectableRegion` overview so it says the region
enables selection for widgets that participate in selection, rather than
implying every child widget becomes selectable automatically.

## Tests

- `./bin/dart format --output=none --set-exit-if-changed
packages/flutter/lib/src/widgets/basic.dart
packages/flutter/lib/src/widgets/selectable_region.dart`
- `./bin/flutter analyze packages/flutter/lib/src/widgets/basic.dart
packages/flutter/lib/src/widgets/selectable_region.dart`
- `./bin/dart --enable-asserts dev/bots/analyze_snippet_code.dart
packages/flutter/lib/src/widgets`
- `git diff --check`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD f: selection SelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIs framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SelectionArea doesn't seem to work with RichText Widget

3 participants