Enable no_default_cases lint (#91530)

This commit is contained in:
Ian Hickson
2021-10-11 10:23:04 -07:00
committed by GitHub
parent 66ff778602
commit 7b01346c5c
52 changed files with 337 additions and 90 deletions

View File

@@ -64,7 +64,7 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
case FilterType.opacity: return 'Fading Child Animation';
case FilterType.rotateTransform: return 'Transformed Child Animation';
case FilterType.rotateFilter: return 'Matrix Filtered Child Animation';
default: return 'Static Child';
case null: return 'Static Child';
}
}

View File

@@ -70,8 +70,10 @@ void _setTestMode(_TestMode? mode) {
case _TestMode.useCanvasTextLayout:
useCanvasText = true;
break;
default:
case _TestMode.useCanvasKit:
case null:
// Keep as null.
break;
}
js_util.callMethod(
html.window,

View File

@@ -74,8 +74,6 @@ abstract class DeviceDiscovery {
case DeviceOperatingSystem.fake:
print('Looking for fake devices! You should not see this in release builds.');
return FakeDeviceDiscovery();
default:
throw DeviceException('Unsupported device operating system: $deviceOperatingSystem');
}
}

View File

@@ -47,7 +47,7 @@ class TestStepResult {
return snapshot.data!;
}
return snapshot.error! as TestStepResult;
default:
case ConnectionState.active:
throw 'Unsupported state ${snapshot.connectionState}';
}
}

View File

@@ -257,8 +257,6 @@ class CalcExpression {
case ExpressionState.NumberWithPoint:
case ExpressionState.Result:
return appendOperation(Operation.Subtraction);
default:
return null;
}
}

View File

@@ -608,7 +608,7 @@ class Tab2ConversationBubble extends StatelessWidget {
backgroundColor = CupertinoTheme.of(context).primaryColor;
foregroundColor = CupertinoColors.white;
break;
default:
case null:
break;
}

View File

@@ -219,7 +219,7 @@ class _ListDemoState extends State<ListDemo> {
case _MaterialListType.threeLine:
itemTypeText = 'Three-line';
break;
default:
case null:
break;
}

View File

@@ -156,7 +156,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
),
);
break;
default:
case null:
listTile = Container(
key: Key(item.value),
);

View File

@@ -169,8 +169,6 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
return Tab(icon: Icon(page.icon));
case TabsDemoStyle.textOnly:
return Tab(text: page.text);
default:
return Tab();
}
}).toList()
),

View File

@@ -90,7 +90,7 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape {
case Thumb.end:
thumbPath = _leftTriangle(size, center);
break;
default:
case null:
break;
}
break;
@@ -102,11 +102,11 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape {
case Thumb.end:
thumbPath = _rightTriangle(size, center);
break;
default:
case null:
break;
}
break;
default:
case null:
break;
}
canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)!);

View File

@@ -116,7 +116,7 @@ class CutCornersBorder extends OutlineInputBorder {
canvas.drawPath(path, paint);
break;
}
default:
case null:
break;
}
}

View File

@@ -408,8 +408,8 @@ class _PlatformItem extends StatelessWidget {
final GalleryOptions? options;
final ValueChanged<GalleryOptions>? onOptionsChanged;
String? _platformLabel(TargetPlatform? platform) {
switch(platform) {
String _platformLabel(TargetPlatform platform) {
switch (platform) {
case TargetPlatform.android:
return 'Mountain View';
case TargetPlatform.fuchsia:
@@ -422,9 +422,6 @@ class _PlatformItem extends StatelessWidget {
return 'Material Desktop (macOS)';
case TargetPlatform.windows:
return 'Material Desktop (Windows)';
default:
assert(false);
return null;
}
}
@@ -439,7 +436,7 @@ class _PlatformItem extends StatelessWidget {
children: <Widget>[
const Text('Platform mechanics'),
Text(
_platformLabel(options!.platform)!,
_platformLabel(options!.platform!),
style: Theme.of(context).primaryTextTheme.bodyText2,
),
],
@@ -452,7 +449,7 @@ class _PlatformItem extends StatelessWidget {
return TargetPlatform.values.map((TargetPlatform platform) {
return PopupMenuItem<TargetPlatform>(
value: platform,
child: Text(_platformLabel(platform)!),
child: Text(_platformLabel(platform)),
);
}).toList();
},

View File

@@ -28,7 +28,7 @@ class TestStepResult {
final Object? result = snapshot.error;
return result! as TestStepResult;
}
default:
case ConnectionState.active:
throw 'Unsupported state ${snapshot.connectionState}';
}
}

View File

@@ -291,16 +291,20 @@ class CardCollectionState extends State<CardCollection> {
case DismissDirection.startToEnd:
backgroundMessage = 'Swipe right to dismiss';
break;
default:
case DismissDirection.vertical:
case DismissDirection.up:
case DismissDirection.down:
case DismissDirection.none:
backgroundMessage = 'Unsupported dismissDirection';
break;
}
// TODO(abarth): This icon is wrong in RTL.
// This icon is wrong in RTL.
Widget leftArrowIcon = const Icon(Icons.arrow_back, size: 36.0);
if (_dismissDirection == DismissDirection.startToEnd)
leftArrowIcon = Opacity(opacity: 0.1, child: leftArrowIcon);
// TODO(abarth): This icon is wrong in RTL.
// This icon is wrong in RTL.
Widget rightArrowIcon = const Icon(Icons.arrow_forward, size: 36.0);
if (_dismissDirection == DismissDirection.endToStart)
rightArrowIcon = Opacity(opacity: 0.1, child: rightArrowIcon);