Skip to content

Slider doesn't repaint on secondaryTrackValue update. #163971

@darkstarx

Description

@darkstarx

Steps to reproduce

  1. Create a Slider with zero secondaryTrackValue and any button.
  2. Schedule updating the value of secondaryTrackValue and don't touch the screen until updating fires.

Expected results

  1. The slider repaints.

Actual results

  1. The slider doesn't show the new secondaryTrackValue.
  2. Hover the button and see repainting of the slider.

The setter _RenderSlider.secondaryTrackValue should call markNeedsPaint instead of markNeedsSemanticsUpdate.

Code sample

Code sample
import 'package:flutter/material.dart';

/// Flutter code sample for [Slider].

void main() => runApp(const SliderApp());

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: SliderExample());
  }
}

class SliderExample extends StatefulWidget {
  const SliderExample({super.key});

  @override
  State<SliderExample> createState() => _SliderExampleState();
}

class _SliderExampleState extends State<SliderExample> {
  double _currentSliderPrimaryValue = 0.0;
  double _currentSliderSecondaryValue = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Slider')),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Slider(
            value: _currentSliderPrimaryValue,
            secondaryTrackValue: _currentSliderSecondaryValue,
            label: _currentSliderPrimaryValue.round().toString(),
            onChanged: (double value) {
              setState(() {
                _currentSliderPrimaryValue = value;
              });
            },
          ),
          ElevatedButton(
            onPressed: () {
              Future.delayed(const Duration(seconds: 1), () {
                setState(() => _currentSliderSecondaryValue = 0.2);
              });
            },
            child: Text('Update secondary value'),
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
2025-02-23.23.59.39.mov

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.4, on macOS 14.6.1 23G93 darwin-x64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.94.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

found in release: 3.30Found to occur in 3.30frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions