-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Closed
Labels
a: fidelityMatching the OEM platforms betterMatching the OEM platforms betterf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 1.21Found to occur in 1.21Found to occur in 1.21frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Description
Minimal reproduction:
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: Center(child: TestSwitch()),
),
));
}
class TestSwitch extends StatefulWidget {
State<TestSwitch> createState() => _TestSwitchState();
}
class _TestSwitchState extends State<TestSwitch> {
static const kDisableSwitchOnChanged = true; // Change me!
bool value = true;
bool enabled = true;
Widget build(BuildContext context) {
return Switch(
value: value,
onChanged: enabled ? _onChanged : null,
);
}
void _onChanged(bool value) {
setState(() {
this.value = value;
if (kDisableSwitchOnChanged) {
enabled = false;
Timer(Duration(seconds: 1), () {
if (mounted) {
setState(() {
enabled = true;
});
}
});
}
});
}
}If kDisableSwitchOnChanged is true, the switch toggle animation does not happen. It instead snaps to the end position.
For comparison, Android settings screen handles this correctly, and Cupertino switch handles it correctly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: fidelityMatching the OEM platforms betterMatching the OEM platforms betterf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 1.21Found to occur in 1.21Found to occur in 1.21frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on