flutter/examples/flutter_gallery/lib/demo/material/slider_demo.dart
xster a76c352d57 Add Cupertino to gallery and add CupertinoButton and many yak friends (#8411)
* Add cupertino to gallery and add CupertinoButto

* Use single quotes

* Add disabled state

* Some review notes

* Make button animation more responsive and tweak timing

* Renamed things Cupertino

* Button with background, move cupertino demos, move material demos

* Move 2 level list too

* Refactor various demo route names

* Some review notes

* More reviews and add test

* Linter as

* Move private constant up
2017-03-01 16:06:48 -08:00

75 lines
2.1 KiB
Dart

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
class SliderDemo extends StatefulWidget {
static const String routeName = '/material/slider';
@override
_SliderDemoState createState() => new _SliderDemoState();
}
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 Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget> [
new Slider(
value: _value,
min: 0.0,
max: 100.0,
thumbOpenAtMin: true,
onChanged: (double value) {
setState(() {
_value = value;
});
}
),
new Text('Continuous'),
]
),
new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget> [
new Slider(value: 0.25, thumbOpenAtMin: true, onChanged: null),
new Text('Disabled'),
]
),
new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget> [
new Slider(
value: _discreteValue,
min: 0.0,
max: 100.0,
divisions: 5,
label: '${_discreteValue.round()}',
thumbOpenAtMin: true,
onChanged: (double value) {
setState(() {
_discreteValue = value;
});
}
),
new Text('Discrete'),
],
),
],
),
),
);
}
}