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:
@@ -163,14 +163,12 @@ class _OptionsState extends State<Options> {
|
||||
double sliderValue = 0.0;
|
||||
|
||||
String _densityToProfile(VisualDensity density) {
|
||||
if (density == VisualDensity.standard) {
|
||||
return 'standard';
|
||||
} else if (density == VisualDensity.compact) {
|
||||
return 'compact';
|
||||
} else if (density == VisualDensity.comfortable) {
|
||||
return 'comfortable';
|
||||
}
|
||||
return 'custom';
|
||||
return switch (density) {
|
||||
VisualDensity.standard => 'standard',
|
||||
VisualDensity.compact => 'compact',
|
||||
VisualDensity.comfortable => 'comfortable',
|
||||
_ => 'custom',
|
||||
};
|
||||
}
|
||||
|
||||
VisualDensity _profileToDensity(String? profile) {
|
||||
|
||||
@@ -70,9 +70,7 @@ class PageViewAppState extends State<PageViewApp> {
|
||||
|
||||
void switchScrollDirection() {
|
||||
setState(() {
|
||||
scrollDirection = (scrollDirection == Axis.vertical)
|
||||
? Axis.horizontal
|
||||
: Axis.vertical;
|
||||
scrollDirection = flipAxis(scrollDirection);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,9 +111,7 @@ class PageViewAppState extends State<PageViewApp> {
|
||||
AppBar _buildAppBar() {
|
||||
return AppBar(
|
||||
title: const Text('PageView'),
|
||||
actions: <Widget>[
|
||||
Text(scrollDirection == Axis.horizontal ? 'horizontal' : 'vertical'),
|
||||
],
|
||||
actions: <Widget>[Text(scrollDirection.name)],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user