Commit 6d313239 authored by Martin's avatar Martin Committed by Anthony

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: 's avatarMartin Staadecker <machstg@gmail.com>

* Undo line wrap from previous commit
Signed-off-by: 's avatarMartin Staadecker <machstg@gmail.com>

* Update onSubmitted to only call setState when value has changed
Signed-off-by: 's avatarMartin Staadecker <machstg@gmail.com>
parent fe701c45
......@@ -36,3 +36,4 @@ TruongSinh Tran-Nguyen <i@truongsinh.pro>
Sander Dalby Larsen <srdlarsen@gmail.com>
Marco Scannadinari <m@scannadinari.co.uk>
Frederik Schweiger <mail@flschweiger.net>
Martin Staadecker <machstg@gmail.com>
......@@ -159,6 +159,49 @@ class _SliderDemoState extends State<SliderDemo> {
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(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment