SelectableRegionState for dynamic toolbar positioning by itsAdityaRathore · Pull Request #183160 · flutter/flutter

@itsAdityaRathore

…r positioning

This commit introduces a new method, refreshToolbar, in the SelectableRegionState class. This method recalculates the toolbar's position based on the current selection geometry, ensuring it updates correctly after layout changes such as scrolling. Additionally, a new test case is added to verify that the toolbar's position is updated appropriately after scrolling within a SelectableRegion.

- Implemented refreshToolbar method to trigger layout updates for the selection overlay.
- Added a test to confirm toolbar repositioning after scrolling.

This enhancement improves the user experience by maintaining the toolbar's visibility and accuracy during text selection scenarios.

@github-actions bot added the framework

flutter/packages/flutter repository. See also f: labels.

label

Mar 3, 2026

gemini-code-assist[bot]

@itsAdityaRathore

This commit adds a null check for the _selectionOverlay in the refreshToolbar method of the SelectableRegionState class. If the _selectionOverlay is null, the method will return early, preventing potential null pointer exceptions. This change enhances the robustness of the toolbar refresh logic during text selection scenarios.