Fix CupertinoSwitch accessibility (#19927)
This commit is contained in:
parent
dfe5b591a6
commit
cded7efbd0
@ -26,42 +26,51 @@ class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo> {
|
|||||||
child: new Column(
|
child: new Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Column(
|
new Semantics(
|
||||||
children: <Widget>[
|
container: true,
|
||||||
new CupertinoSwitch(
|
child: new Column(
|
||||||
value: _switchValue,
|
children: <Widget>[
|
||||||
onChanged: (bool value) {
|
new CupertinoSwitch(
|
||||||
setState(() {
|
value: _switchValue,
|
||||||
_switchValue = value;
|
onChanged: (bool value) {
|
||||||
});
|
setState(() {
|
||||||
},
|
_switchValue = value;
|
||||||
),
|
});
|
||||||
const Text(
|
},
|
||||||
'Active'
|
),
|
||||||
),
|
const Text(
|
||||||
],
|
'Active'
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
new Column(
|
new Semantics(
|
||||||
children: const <Widget>[
|
container: true,
|
||||||
const CupertinoSwitch(
|
child: new Column(
|
||||||
value: true,
|
children: const <Widget>[
|
||||||
onChanged: null,
|
const CupertinoSwitch(
|
||||||
),
|
value: true,
|
||||||
const Text(
|
onChanged: null,
|
||||||
'Disabled'
|
),
|
||||||
),
|
const Text(
|
||||||
],
|
'Disabled'
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
new Column(
|
new Semantics(
|
||||||
children: const <Widget>[
|
container: true,
|
||||||
const CupertinoSwitch(
|
child: new Column(
|
||||||
value: false,
|
children: const <Widget>[
|
||||||
onChanged: null,
|
const CupertinoSwitch(
|
||||||
),
|
value: false,
|
||||||
const Text(
|
onChanged: null,
|
||||||
'Disabled'
|
),
|
||||||
),
|
const Text(
|
||||||
],
|
'Disabled'
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -380,10 +380,11 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
|
|||||||
void describeSemanticsConfiguration(SemanticsConfiguration config) {
|
void describeSemanticsConfiguration(SemanticsConfiguration config) {
|
||||||
super.describeSemanticsConfiguration(config);
|
super.describeSemanticsConfiguration(config);
|
||||||
|
|
||||||
config.isSemanticBoundary = isInteractive;
|
|
||||||
if (isInteractive)
|
if (isInteractive)
|
||||||
config.onTap = _handleTap;
|
config.onTap = _handleTap;
|
||||||
config.isChecked = _value;
|
|
||||||
|
config.isEnabled = isInteractive;
|
||||||
|
config.isToggled = _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CupertinoThumbPainter _thumbPainter = new CupertinoThumbPainter();
|
final CupertinoThumbPainter _thumbPainter = new CupertinoThumbPainter();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user