Skip to content

RangeSlider thumb's center doesn't align with division's center, thumb padding, and rounded corners don't work as expected #159586

@TahaTesser

Description

@TahaTesser

Steps to reproduce

#149591
#62567
#149589

These three issues also exist for RangeSlider widget. This breaks fundamental behaviors such as proper alignment, shape and padding.

Expected results

Thumb's center to align with division's center, proper thumb padding and rounded corners.

Actual results

Screenshot 2024-11-28 at 11 46 59

Code sample

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double _discreetSliderValue = 0.6;
  RangeValues _discreteRangeSliderValues = const RangeValues(0.2, 0.6);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        sliderTheme: const SliderThemeData(
          trackHeight: 32,
          thumbColor: Colors.green,
          activeTrackColor: Colors.deepPurple,
          inactiveTrackColor: Colors.amber,
        ),
      ),
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                'Discrete Slider',
                style: Theme.of(context).textTheme.titleMedium,
              ),
              Slider(
                  value: _discreetSliderValue,
                  divisions: 5,
                  onChanged: (double newValue) {
                    setState(() {
                      _discreetSliderValue = newValue;
                    });
                  }),
              Text(
                'Discrete Range Slider',
                style: Theme.of(context).textTheme.titleMedium,
              ),
              RangeSlider(
                values: _discreteRangeSliderValues,
                divisions: 5,
                onChanged: (RangeValues newValues) {
                  setState(() {
                    _discreteRangeSliderValues = newValues;
                  });
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.found in release: 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions