Updated Material 3 `Slider`
Summary
#The Slider has been updated to match the Material 3 Design specifications.
The Slider changes include an updated height,
a gap between the active and inactive track, and
a stop indicator to show the end value of the inactive track.
Pressing the thumb adjusts its width, and the track adjusts its shape.
The new value indicator shape is a rounded rectangle.
New color mappings have also been introduced for some of the Slider shapes.
Context
#The Material 3 Design specs for the Slider were updated in December 2023.
To opt into the 2024 design spec, set the Slider.year2023 flag to false.
This is done to ensure that existing apps aren't affected by
the updated design specifications.
Description of change
#The Slider widget has a year2023 flag that can be set to false to
opt in to the updated design spec.
The default value for the year2023 flag is true,
which means that the Slider uses the previous 2023 design specifications.
When Slider.year2023 is set to false,
the slider uses the updated design specifications.
Migration guide
#To opt into the updated design spec for the Slider,
set the year2023 flag to false:
Slider(
year2023: false,
value: _value,
onChanged: (value) {
setState(() {
_value = value;
});
},
),To update your entire app to use the updated Slider design, set the
SliderThemeData.year2023 property to false in your MaterialApp:
return MaterialApp(
theme: ThemeData(sliderTheme: const SliderThemeData(year2023: false)),
// ...
Slider(
value: _value,
onChanged: (value) {
setState(() {
_value = value;
});
},
),
// ...Timeline
#Landed in version: 3.28.0-0.1.pre
In stable release: 3.29
References
#API documentation:
Relevant issues:
Relevant PRs:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2025-02-26。 查看文档源码 或者 为本页面内容提出建议.