Reland "if chains → switch expressions" (#148634)
I did a goof a while back:

Now that [the bug is fixed](e9d403541f), I think we're good to re-implement the if-chains cleanup!
Related:
- https://github.com/flutter/flutter/pull/147793
- https://github.com/flutter/flutter/pull/148556
- https://github.com/flutter/flutter/issues/148548
This commit is contained in:
@@ -123,13 +123,10 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
const Text('Multi Line Text'),
|
||||
Switch(
|
||||
value: _multiLine,
|
||||
onChanged: _snackBarBehavior == SnackBarBehavior.fixed
|
||||
? null
|
||||
: (bool value) {
|
||||
setState(() {
|
||||
_multiLine = !_multiLine;
|
||||
});
|
||||
},
|
||||
onChanged: switch (_snackBarBehavior) {
|
||||
SnackBarBehavior.fixed || null => null,
|
||||
SnackBarBehavior.floating => (bool value) => setState(() { _multiLine = !_multiLine; }),
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -139,13 +136,10 @@ class _SnackBarExampleState extends State<SnackBarExample> {
|
||||
value: _sliderValue,
|
||||
divisions: 20,
|
||||
label: _sliderValue.toStringAsFixed(2),
|
||||
onChanged: _snackBarBehavior == SnackBarBehavior.fixed
|
||||
? null
|
||||
: (double value) {
|
||||
setState(() {
|
||||
_sliderValue = value;
|
||||
});
|
||||
},
|
||||
onChanged: switch (_snackBarBehavior) {
|
||||
SnackBarBehavior.fixed || null => null,
|
||||
SnackBarBehavior.floating => (double value) => setState(() { _sliderValue = value; }),
|
||||
},
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16.0),
|
||||
|
||||
Reference in New Issue
Block a user