Create slider with editable numerical value in gallery (#23506)
* Update doc header in Opacity class to fix issue #23311 * Added slider with editable numerical value to gallery. Fixes flutter#1542 * Revert "Update doc header in Opacity class to fix issue #23311" This reverts commit 2d3642bbda6e00389e78631360f8274e9bb7d675. * Fix typo in slider description * Increase TextField size to pass accessibility test * Added Semantics widget to pass accessibility test * Made description start with caps to match other examples * Removed unnecessary spacing Container widget * Update authors file * Fix indent * Removed decimal and replaced boundaries with .clamp Signed-off-by: Martin Staadecker <machstg@gmail.com> * Undo line wrap from previous commit Signed-off-by: Martin Staadecker <machstg@gmail.com> * Update onSubmitted to only call setState when value has changed Signed-off-by: Martin Staadecker <machstg@gmail.com>
This commit is contained in:
parent
fe701c45e5
commit
6d31323971
1
AUTHORS
1
AUTHORS
@ -36,3 +36,4 @@ TruongSinh Tran-Nguyen <i@truongsinh.pro>
|
|||||||
Sander Dalby Larsen <srdlarsen@gmail.com>
|
Sander Dalby Larsen <srdlarsen@gmail.com>
|
||||||
Marco Scannadinari <m@scannadinari.co.uk>
|
Marco Scannadinari <m@scannadinari.co.uk>
|
||||||
Frederik Schweiger <mail@flschweiger.net>
|
Frederik Schweiger <mail@flschweiger.net>
|
||||||
|
Martin Staadecker <machstg@gmail.com>
|
||||||
|
@ -159,6 +159,49 @@ class _SliderDemoState extends State<SliderDemo> {
|
|||||||
const Text('Continuous'),
|
const Text('Continuous'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Slider(
|
||||||
|
value: _value,
|
||||||
|
min: 0.0,
|
||||||
|
max: 100.0,
|
||||||
|
onChanged: (double value) {
|
||||||
|
setState(() {
|
||||||
|
_value = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Semantics(
|
||||||
|
label: 'Editable numerical value',
|
||||||
|
child: Container(
|
||||||
|
width: 48,
|
||||||
|
height: 48,
|
||||||
|
child: TextField(
|
||||||
|
onSubmitted: (String value) {
|
||||||
|
final double newValue = double.tryParse(value);
|
||||||
|
if (newValue != null && newValue != _value) {
|
||||||
|
setState(() {
|
||||||
|
_value = newValue.clamp(0, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
controller: TextEditingController(
|
||||||
|
text: _value.toStringAsFixed(0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Text('Continuous with Editable Numerical Value'),
|
||||||
|
],
|
||||||
|
),
|
||||||
Column(
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user