Skip to content

[material_ui] Port flutter/flutter #181525 "Add keyboard support for RangeSlider" - #12687

Open
xxxOVALxxx wants to merge 1 commit into
flutter:mainfrom
xxxOVALxxx:keyboard_support_for_range_slider
Open

[material_ui] Port flutter/flutter #181525 "Add keyboard support for RangeSlider"#12687
xxxOVALxxx wants to merge 1 commit into
flutter:mainfrom
xxxOVALxxx:keyboard_support_for_range_slider

Conversation

@xxxOVALxxx

Copy link
Copy Markdown

This PR ports flutter/flutter#181525 from flutter/flutter to flutter/packages.

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Aug 29, 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 implements keyboard navigation support for the RangeSlider widget, enabling value adjustments via arrow keys in both traditional and directional navigation modes. It introduces shortcut and action mappings, exposes semantic adjustment methods on the render object, and adds tests to verify the behavior. The review feedback recommends avoiding the force-unwrap operator on _renderObjectKey.currentContext in the action handler to prevent potential runtime exceptions if the widget is not fully mounted.

Comment on lines +603 to +605
void _actionHandler(_AdjustSliderIntent intent, Thumb thumb) {
final slider = _renderObjectKey.currentContext!.findRenderObject()! as _RenderRangeSlider;
final TextDirection directionality = Directionality.of(_renderObjectKey.currentContext!);

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.

medium

To adhere to defensive programming practices, we should avoid using the force-unwrap operator ! on _renderObjectKey.currentContext directly. If the action is triggered during a transition or when the widget is not fully mounted, currentContext could be null, leading to a runtime exception. Checking for null first is safer.

  void _actionHandler(_AdjustSliderIntent intent, Thumb thumb) {
    final BuildContext? context = _renderObjectKey.currentContext;
    if (context == null) {
      return;
    }
    final _RenderRangeSlider slider = context.findRenderObject()! as _RenderRangeSlider;
    final TextDirection directionality = Directionality.of(context);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant