Refactoring if chains into switch statements (#144905)
Based on issue #144903, this PR aims to bring the codebase more in line with the [Flutter repo style guide](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-using-if-chains-or--or--with-enum-values): > #### Avoid using `if` chains or `?:` or `==` with enum values <br> This change unfortunately increases the total line length, but it also improves readability.
This commit is contained in:
@@ -40,14 +40,15 @@ class NavigationIconView {
|
||||
|
||||
FadeTransition transition(BottomNavigationBarType type, BuildContext context) {
|
||||
Color? iconColor;
|
||||
if (type == BottomNavigationBarType.shifting) {
|
||||
iconColor = _color;
|
||||
} else {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final ColorScheme colorScheme = theme.colorScheme;
|
||||
iconColor = theme.brightness == Brightness.light
|
||||
? colorScheme.primary
|
||||
: colorScheme.secondary;
|
||||
switch (type) {
|
||||
case BottomNavigationBarType.shifting:
|
||||
iconColor = _color;
|
||||
case BottomNavigationBarType.fixed:
|
||||
final ThemeData theme = Theme.of(context);
|
||||
iconColor = switch (theme.brightness) {
|
||||
Brightness.light => theme.colorScheme.primary,
|
||||
Brightness.dark => theme.colorScheme.secondary,
|
||||
};
|
||||
}
|
||||
|
||||
return FadeTransition(
|
||||
|
||||
Reference in New Issue
Block a user