if chains → switch expressions (#147793)

Previous "if-chains" pull requests:
- https://github.com/flutter/flutter/pull/144905
- https://github.com/flutter/flutter/pull/144977
- https://github.com/flutter/flutter/pull/145194
- https://github.com/flutter/flutter/pull/146293
- https://github.com/flutter/flutter/pull/147472

<br>

I think this one should be enough to wrap things up!

fixes https://github.com/flutter/flutter/issues/144903

---------

Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
This commit is contained in:
Nate
2024-05-10 00:55:48 -06:00
committed by GitHub
parent c90e18c6f5
commit 4734d80f22
33 changed files with 194 additions and 297 deletions

View File

@@ -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),