@@ -11,53 +11,44 @@ class SliderDemo extends StatefulWidget {
|
||||
|
||||
class _SliderDemoState extends State<SliderDemo> {
|
||||
double _value = 25.0;
|
||||
double _discreteValue = 20.0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: new Text("Sliders")),
|
||||
body: new Block(children: <Widget>[
|
||||
new Container(
|
||||
height: 100.0,
|
||||
child: new Center(
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Slider(
|
||||
value: _value,
|
||||
min: 0.0,
|
||||
max: 100.0,
|
||||
onChanged: (double value) {
|
||||
setState(() {
|
||||
_value = value;
|
||||
});
|
||||
}
|
||||
),
|
||||
new Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new Text(_value.round().toString().padLeft(3, '0'))
|
||||
),
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.collapse
|
||||
appBar: new AppBar(title: new Text('Sliders')),
|
||||
body: new Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
new Center(
|
||||
child: new Slider(
|
||||
value: _value,
|
||||
min: 0.0,
|
||||
max: 100.0,
|
||||
onChanged: (double value) {
|
||||
setState(() {
|
||||
_value = value;
|
||||
});
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
new Container(
|
||||
height: 100.0,
|
||||
child: new Center(
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
// Disabled, but tracking the slider above.
|
||||
new Slider(value: _value / 100.0),
|
||||
new Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: new Text((_value / 100.0).toStringAsFixed(2))
|
||||
),
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.collapse
|
||||
),
|
||||
new Center(child: new Slider(value: _value / 100.0)),
|
||||
new Center(
|
||||
child: new Slider(
|
||||
value: _discreteValue,
|
||||
min: 0.0,
|
||||
max: 100.0,
|
||||
divisions: 5,
|
||||
label: '${_discreteValue.round()}',
|
||||
onChanged: (double value) {
|
||||
setState(() {
|
||||
_discreteValue = value;
|
||||
});
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
])
|
||||
),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user