提交 27854744 编写于 作者: H hdx

test_flutter_slider_100: 显示 value 值,限制值范围(0-100)

上级 4b7a7868
......@@ -45,7 +45,7 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
double _currentSliderValue = 0.5;
double _currentSliderValue = 50;
void onSliderChanged(double value) {
setState(() {
......@@ -68,7 +68,19 @@ class _MyHomePageState extends State<MyHomePage> {
crossAxisCount: 4,
// Generate 100 widgets that display their index in the List.
children: List.generate(100, (index) {
return Slider(value: _currentSliderValue, onChanged: onSliderChanged);
return Flex(
direction: Axis.horizontal,
children: [
Expanded(
flex: 1,
child: Slider(min: 0, max: 100, value: _currentSliderValue, onChanged: onSliderChanged),
),
SizedBox(
width: 26,
child: Text(_currentSliderValue.toStringAsFixed(0)),
),
],
);
}),
),
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册