Unverified Commit 7b01346c authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Enable no_default_cases lint (#91530)

parent 66ff7786
......@@ -127,7 +127,7 @@ linter:
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
# - no_default_cases # too many false positives
- no_default_cases
- no_duplicate_case_values
- no_logic_in_create_state
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
......
......@@ -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';
}
}
......
......@@ -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,
......
......@@ -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');
}
}
......
......@@ -47,7 +47,7 @@ class TestStepResult {
return snapshot.data!;
}
return snapshot.error! as TestStepResult;
default:
case ConnectionState.active:
throw 'Unsupported state ${snapshot.connectionState}';
}
}
......
......@@ -257,8 +257,6 @@ class CalcExpression {
case ExpressionState.NumberWithPoint:
case ExpressionState.Result:
return appendOperation(Operation.Subtraction);
default:
return null;
}
}
......
......@@ -608,7 +608,7 @@ class Tab2ConversationBubble extends StatelessWidget {
backgroundColor = CupertinoTheme.of(context).primaryColor;
foregroundColor = CupertinoColors.white;
break;
default:
case null:
break;
}
......
......@@ -219,7 +219,7 @@ class _ListDemoState extends State<ListDemo> {
case _MaterialListType.threeLine:
itemTypeText = 'Three-line';
break;
default:
case null:
break;
}
......
......@@ -156,7 +156,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
),
);
break;
default:
case null:
listTile = Container(
key: Key(item.value),
);
......
......@@ -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()
),
......
......@@ -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)!);
......
......@@ -116,7 +116,7 @@ class CutCornersBorder extends OutlineInputBorder {
canvas.drawPath(path, paint);
break;
}
default:
case null:
break;
}
}
......
......@@ -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();
},
......
......@@ -28,7 +28,7 @@ class TestStepResult {
final Object? result = snapshot.error;
return result! as TestStepResult;
}
default:
case ConnectionState.active:
throw 'Unsupported state ${snapshot.connectionState}';
}
}
......
......@@ -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);
......
......@@ -281,7 +281,6 @@ class IsolateExampleState extends State<StatefulWidget> with SingleTickerProvide
case CalculationState.calculating:
return 'In Progress';
case CalculationState.idle:
default:
return 'Idle';
}
}
......
......@@ -287,7 +287,8 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
});
break;
default:
case AnimationStatus.forward:
case AnimationStatus.reverse:
return;
}
}
......
......@@ -566,7 +566,9 @@ class _PackagesViewState extends State<_PackagesView> {
);
},
);
default:
case ConnectionState.none:
case ConnectionState.active:
case ConnectionState.waiting:
return Material(
color: Theme.of(context).cardColor,
child: Column(
......
......@@ -406,7 +406,10 @@ class _RenderButtonBarRow extends RenderFlex {
case MainAxisAlignment.end:
childParentData.offset = Offset(constraints.maxWidth - child.size.width, currentHeight);
break;
default:
case MainAxisAlignment.spaceAround:
case MainAxisAlignment.spaceBetween:
case MainAxisAlignment.spaceEvenly:
case MainAxisAlignment.start:
childParentData.offset = Offset(0, currentHeight);
break;
}
......@@ -420,7 +423,10 @@ class _RenderButtonBarRow extends RenderFlex {
case MainAxisAlignment.end:
childParentData.offset = Offset(0, currentHeight);
break;
default:
case MainAxisAlignment.spaceAround:
case MainAxisAlignment.spaceBetween:
case MainAxisAlignment.spaceEvenly:
case MainAxisAlignment.start:
childParentData.offset = Offset(constraints.maxWidth - child.size.width, currentHeight);
break;
}
......
......@@ -1654,7 +1654,10 @@ class _CalendarDateRangePickerState extends State<_CalendarDateRangePicker> {
case TargetPlatform.fuchsia:
HapticFeedback.vibrate();
break;
default:
case TargetPlatform.iOS:
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
break;
}
}
......
......@@ -374,7 +374,8 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
case AnimationStatus.dismissed:
_controller.value = widget.isDrawerOpen ? 1.0 : 0.0;
break;
default:
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
}
}
......
......@@ -350,7 +350,9 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
case MaterialType.card:
color = theme.cardColor;
break;
default:
case MaterialType.button:
case MaterialType.circle:
case MaterialType.transparency:
break;
}
}
......
......@@ -636,7 +636,10 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
return formatDecimal(timeOfDay.hourOfPeriod == 0 ? 12 : timeOfDay.hourOfPeriod);
case TimeOfDayFormat.HH_colon_mm:
return _formatTwoDigitZeroPad(timeOfDay.hour);
default:
case TimeOfDayFormat.a_space_h_colon_mm:
case TimeOfDayFormat.frenchCanadian:
case TimeOfDayFormat.H_colon_mm:
case TimeOfDayFormat.HH_dot_mm:
throw AssertionError('$runtimeType does not support $format.');
}
}
......
......@@ -346,7 +346,11 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
case _RefreshIndicatorMode.drag:
_dismiss(_RefreshIndicatorMode.canceled);
break;
default:
case _RefreshIndicatorMode.canceled:
case _RefreshIndicatorMode.done:
case _RefreshIndicatorMode.refresh:
case _RefreshIndicatorMode.snap:
case null:
// do nothing
break;
}
......@@ -407,14 +411,17 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
setState(() {
_mode = newMode;
});
switch (_mode) {
switch (_mode!) {
case _RefreshIndicatorMode.done:
await _scaleController.animateTo(1.0, duration: _kIndicatorScaleDuration);
break;
case _RefreshIndicatorMode.canceled:
await _positionController.animateTo(0.0, duration: _kIndicatorScaleDuration);
break;
default:
case _RefreshIndicatorMode.armed:
case _RefreshIndicatorMode.drag:
case _RefreshIndicatorMode.refresh:
case _RefreshIndicatorMode.snap:
assert(false);
}
if (mounted && _mode == newMode) {
......
......@@ -100,7 +100,7 @@ class MaterialTextSelectionControls extends TextSelectionControls {
return const Offset(_kHandleSize, 0);
case TextSelectionHandleType.right:
return Offset.zero;
default:
case TextSelectionHandleType.collapsed:
return const Offset(_kHandleSize / 2, -4);
}
}
......
......@@ -360,7 +360,9 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
case TargetPlatform.linux:
case TargetPlatform.windows:
return 24.0;
default:
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:
return 32.0;
}
}
......@@ -372,7 +374,9 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
case TargetPlatform.linux:
case TargetPlatform.windows:
return const EdgeInsets.symmetric(horizontal: 8.0);
default:
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:
return const EdgeInsets.symmetric(horizontal: 16.0);
}
}
......@@ -384,7 +388,9 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
case TargetPlatform.linux:
case TargetPlatform.windows:
return 10.0;
default:
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:
return 14.0;
}
}
......
......@@ -1990,7 +1990,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
_placeholderSpans[childIndex].baseline!,
);
break;
default:
case ui.PlaceholderAlignment.aboveBaseline:
case ui.PlaceholderAlignment.belowBaseline:
case ui.PlaceholderAlignment.bottom:
case ui.PlaceholderAlignment.middle:
case ui.PlaceholderAlignment.top:
baselineOffset = null;
break;
}
......
......@@ -554,7 +554,11 @@ class RenderParagraph extends RenderBox
_placeholderSpans[childIndex].baseline!,
);
break;
default:
case ui.PlaceholderAlignment.aboveBaseline:
case ui.PlaceholderAlignment.belowBaseline:
case ui.PlaceholderAlignment.bottom:
case ui.PlaceholderAlignment.middle:
case ui.PlaceholderAlignment.top:
baselineOffset = null;
break;
}
......
......@@ -2466,7 +2466,12 @@ class RenderFittedBox extends RenderProxyBox {
switch (fit) {
case BoxFit.scaleDown:
return true;
default:
case BoxFit.contain:
case BoxFit.cover:
case BoxFit.fill:
case BoxFit.fitHeight:
case BoxFit.fitWidth:
case BoxFit.none:
return false;
}
}
......@@ -2551,7 +2556,12 @@ class RenderFittedBox extends RenderProxyBox {
final BoxConstraints sizeConstraints = constraints.loosen();
final Size unconstrainedSize = sizeConstraints.constrainSizeAndAttemptToPreserveAspectRatio(childSize);
return constraints.constrain(unconstrainedSize);
default:
case BoxFit.contain:
case BoxFit.cover:
case BoxFit.fill:
case BoxFit.fitHeight:
case BoxFit.fitWidth:
case BoxFit.none:
return constraints.constrainSizeAndAttemptToPreserveAspectRatio(childSize);
}
} else {
......@@ -2569,7 +2579,12 @@ class RenderFittedBox extends RenderProxyBox {
final Size unconstrainedSize = sizeConstraints.constrainSizeAndAttemptToPreserveAspectRatio(child!.size);
size = constraints.constrain(unconstrainedSize);
break;
default:
case BoxFit.contain:
case BoxFit.cover:
case BoxFit.fill:
case BoxFit.fitHeight:
case BoxFit.fitWidth:
case BoxFit.none:
size = constraints.constrainSizeAndAttemptToPreserveAspectRatio(child!.size);
break;
}
......
......@@ -69,7 +69,7 @@ KeyEventResult combineKeyEventResults(Iterable<KeyEventResult> results) {
case KeyEventResult.skipRemainingHandlers:
hasSkipRemainingHandlers = true;
break;
default:
case KeyEventResult.ignored:
break;
}
}
......
......@@ -2593,7 +2593,8 @@ Map<DismissDirection, List<Offset>> _getDragGesturesOfDismissDirections(double s
Offset(-scaffoldWidth, 0.0), // drag to left gesture
];
break;
default:
case DismissDirection.none:
break;
}
}
......
......@@ -389,8 +389,24 @@ void _defineTests() {
case SemanticsAction.setText:
semanticsOwner.performAction(expectedId, action, 'text');
break;
default:
case SemanticsAction.copy:
case SemanticsAction.customAction:
case SemanticsAction.cut:
case SemanticsAction.decrease:
case SemanticsAction.didGainAccessibilityFocus:
case SemanticsAction.didLoseAccessibilityFocus:
case SemanticsAction.dismiss:
case SemanticsAction.increase:
case SemanticsAction.longPress:
case SemanticsAction.paste:
case SemanticsAction.scrollDown:
case SemanticsAction.scrollLeft:
case SemanticsAction.scrollRight:
case SemanticsAction.scrollUp:
case SemanticsAction.showOnScreen:
case SemanticsAction.tap:
semanticsOwner.performAction(expectedId, action);
break;
}
expect(performedActions.length, expectedLength);
expect(performedActions.last, action);
......
......@@ -493,8 +493,26 @@ void main() {
case SemanticsAction.setText:
semanticsOwner.performAction(expectedId, action, 'text');
break;
default:
case SemanticsAction.copy:
case SemanticsAction.customAction:
case SemanticsAction.cut:
case SemanticsAction.decrease:
case SemanticsAction.didGainAccessibilityFocus:
case SemanticsAction.didLoseAccessibilityFocus:
case SemanticsAction.dismiss:
case SemanticsAction.increase:
case SemanticsAction.longPress:
case SemanticsAction.moveCursorBackwardByWord:
case SemanticsAction.moveCursorForwardByWord:
case SemanticsAction.paste:
case SemanticsAction.scrollDown:
case SemanticsAction.scrollLeft:
case SemanticsAction.scrollRight:
case SemanticsAction.scrollUp:
case SemanticsAction.showOnScreen:
case SemanticsAction.tap:
semanticsOwner.performAction(expectedId, action);
break;
}
expect(performedActions.length, expectedLength);
expect(performedActions.last, action);
......
......@@ -593,8 +593,6 @@ List<String> _timelineStreamsToString(List<TimelineStream> streams) {
case TimelineStream.gc: return 'GC';
case TimelineStream.isolate: return 'Isolate';
case TimelineStream.vm: return 'VM';
default:
throw 'Unknown timeline stream $stream';
}
}).toList();
}
......
......@@ -236,9 +236,20 @@ class AndroidDevice extends Device {
return buildMode != BuildMode.jitRelease;
case TargetPlatform.android_x86:
return buildMode == BuildMode.debug;
default:
case TargetPlatform.android:
case TargetPlatform.darwin:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.ios:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
case TargetPlatform.windows_x64:
throw UnsupportedError('Invalid target platform for Android');
}
throw null; // dead code, remove after null migration
}
@override
......@@ -560,7 +571,17 @@ class AndroidDevice extends Device {
case TargetPlatform.android_x86:
androidArch = AndroidArch.x86;
break;
default:
case TargetPlatform.android:
case TargetPlatform.darwin:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.ios:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
case TargetPlatform.windows_x64:
_logger.printError('Android platforms are only supported.');
return LaunchResult.failed();
}
......
......@@ -420,10 +420,12 @@ class CachedArtifacts implements Artifacts {
}) {
platform = _mapTargetPlatform(platform);
switch (platform) {
case TargetPlatform.android:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
assert(platform != TargetPlatform.android);
return _getAndroidArtifactPath(artifact, platform!, mode!);
case TargetPlatform.ios:
return _getIosArtifactPath(artifact, platform!, mode, environmentType);
......@@ -438,7 +440,7 @@ class CachedArtifacts implements Artifacts {
return _getFuchsiaArtifactPath(artifact, platform!, mode!);
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
default: // could be null, but that can't be specified as a case.
case null:
return _getHostArtifactPath(artifact, platform ?? _currentHostPlatform(_platform, _operatingSystemUtils), mode);
}
}
......@@ -468,7 +470,29 @@ class CachedArtifacts implements Artifacts {
assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.');
final String hostPlatform = getNameForHostPlatform(getCurrentHostPlatform());
return _fileSystem.path.join(engineDir, hostPlatform, _artifactToFileName(artifact));
default:
case Artifact.constFinder:
case Artifact.flutterFramework:
case Artifact.flutterMacOSFramework:
case Artifact.flutterMacOSPodspec:
case Artifact.flutterPatchedSdkPath:
case Artifact.flutterTester:
case Artifact.flutterXcframework:
case Artifact.fontSubset:
case Artifact.fuchsiaFlutterRunner:
case Artifact.fuchsiaKernelCompiler:
case Artifact.icuData:
case Artifact.isolateSnapshotData:
case Artifact.linuxDesktopPath:
case Artifact.linuxHeaders:
case Artifact.platformKernelDill:
case Artifact.platformLibrariesJson:
case Artifact.skyEnginePath:
case Artifact.uwptool:
case Artifact.vmSnapshotData:
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.windowsUwpCppClientWrapper:
case Artifact.windowsUwpDesktopPath:
return _getHostArtifactPath(artifact, platform, mode);
}
}
......@@ -484,7 +508,27 @@ class CachedArtifacts implements Artifacts {
case Artifact.flutterFramework:
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
return _getIosEngineArtifactPath(engineDir, environmentType, _fileSystem);
default:
case Artifact.constFinder:
case Artifact.flutterMacOSFramework:
case Artifact.flutterMacOSPodspec:
case Artifact.flutterPatchedSdkPath:
case Artifact.flutterTester:
case Artifact.fontSubset:
case Artifact.fuchsiaFlutterRunner:
case Artifact.fuchsiaKernelCompiler:
case Artifact.icuData:
case Artifact.isolateSnapshotData:
case Artifact.linuxDesktopPath:
case Artifact.linuxHeaders:
case Artifact.platformKernelDill:
case Artifact.platformLibrariesJson:
case Artifact.skyEnginePath:
case Artifact.uwptool:
case Artifact.vmSnapshotData:
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.windowsUwpCppClientWrapper:
case Artifact.windowsUwpDesktopPath:
return _getHostArtifactPath(artifact, platform, mode);
}
}
......@@ -513,7 +557,26 @@ class CachedArtifacts implements Artifacts {
case Artifact.fuchsiaFlutterRunner:
final String artifactFileName = _artifactToFileName(artifact, platform, mode)!;
return _fileSystem.path.join(root, runtime, artifactFileName);
default:
case Artifact.constFinder:
case Artifact.flutterFramework:
case Artifact.flutterMacOSFramework:
case Artifact.flutterMacOSPodspec:
case Artifact.flutterTester:
case Artifact.flutterXcframework:
case Artifact.fontSubset:
case Artifact.frontendServerSnapshotForEngineDartSdk:
case Artifact.icuData:
case Artifact.isolateSnapshotData:
case Artifact.linuxDesktopPath:
case Artifact.linuxHeaders:
case Artifact.platformLibrariesJson:
case Artifact.skyEnginePath:
case Artifact.uwptool:
case Artifact.vmSnapshotData:
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.windowsUwpCppClientWrapper:
case Artifact.windowsUwpDesktopPath:
return _getHostArtifactPath(artifact, platform, mode);
}
}
......@@ -586,7 +649,10 @@ class CachedArtifacts implements Artifacts {
.childDirectory('windows-uwp-x64-${getNameForBuildMode(mode ?? BuildMode.debug)}')
.childFile(_artifactToFileName(artifact, platform, mode)!)
.path;
default:
case Artifact.flutterFramework:
case Artifact.flutterXcframework:
case Artifact.fuchsiaFlutterRunner:
case Artifact.fuchsiaKernelCompiler:
throw StateError('Artifact $artifact not available for platform $platform.');
}
}
......
......@@ -718,7 +718,19 @@ String fuchsiaArchForTargetPlatform(TargetPlatform targetPlatform) {
return 'arm64';
case TargetPlatform.fuchsia_x64:
return 'x64';
default:
case TargetPlatform.android:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
case TargetPlatform.darwin:
case TargetPlatform.ios:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
case TargetPlatform.windows_x64:
throw UnsupportedError('Unexpected Fuchsia platform $targetPlatform');
}
}
......@@ -963,7 +975,17 @@ String getNameForTargetPlatformArch(TargetPlatform platform) {
return 'x64';
case TargetPlatform.linux_arm64:
return 'arm64';
default:
case TargetPlatform.android:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.ios:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
throw UnsupportedError('Unexpected target platform $platform');
}
}
......
......@@ -193,8 +193,20 @@ class KernelSnapshot extends Target {
case TargetPlatform.linux_x64:
forceLinkPlatform = true;
break;
default:
case TargetPlatform.android:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.ios:
case TargetPlatform.linux_arm64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
forceLinkPlatform = false;
break;
}
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
......
......@@ -111,16 +111,27 @@ class BuildBundleCommand extends BuildSubCommand {
}
break;
case TargetPlatform.windows_x64:
case TargetPlatform.windows_uwp_x64:
if (!featureFlags.isWindowsEnabled) {
throwToolExit('Windows is not a supported target platform.');
}
break;
case TargetPlatform.linux_x64:
case TargetPlatform.linux_arm64:
if (!featureFlags.isLinuxEnabled) {
throwToolExit('Linux is not a supported target platform.');
}
break;
default:
case TargetPlatform.android:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.ios:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
break;
}
......
......@@ -287,7 +287,7 @@ abstract class CreateBase extends FlutterCommand {
final FileSystemEntityType type = globals.fs.typeSync(projectDirPath);
switch (type) {
switch (type) { // ignore: exhaustive_cases, https://github.com/dart-lang/linter/issues/3017
case FileSystemEntityType.file:
// Do not overwrite files.
throwToolExit("Invalid project name: '$projectDirPath' - file exists.",
......@@ -298,7 +298,9 @@ abstract class CreateBase extends FlutterCommand {
throwToolExit("Invalid project name: '$projectDirPath' - refers to a link.",
exitCode: 2);
break;
default:
case FileSystemEntityType.directory:
case FileSystemEntityType.notFound:
break;
}
}
......
......@@ -269,11 +269,14 @@ class IdeConfigCommand extends FlutterCommand {
String _validateFlutterDir(String dirPath, { String flutterRoot }) {
final FileSystemEntityType type = globals.fs.typeSync(dirPath);
switch (type) {
switch (type) { // ignore: exhaustive_cases, https://github.com/dart-lang/linter/issues/3017
case FileSystemEntityType.link:
// Do not overwrite links.
return "Invalid project root dir: '$dirPath' - refers to a link.";
default:
case FileSystemEntityType.file:
case FileSystemEntityType.directory:
case FileSystemEntityType.notFound:
return null;
}
return null; // dead code, remove after null safety migration
}
......@@ -850,7 +850,10 @@ class PubspecYaml {
}
endOfDevDependencies = output.length;
break;
default:
case Section.builders:
case Section.dependencyOverrides:
case Section.header:
case Section.other:
// In other sections, pass everything through in its original form.
output.add(data.line);
if (data.lockLine != null) {
......
......@@ -126,8 +126,6 @@ class GroupedValidator extends DoctorValidator {
mergedType = ValidationType.partial;
}
break;
default:
throw 'Unrecognized validation type: ${result.type}';
}
mergedMessages.addAll(result.messages);
}
......
......@@ -317,9 +317,8 @@ Map<String, dynamic> getDesiredCapabilities(Browser browser, bool headless, [Str
'args': <String>['--disable-fullscreen']
},
};
default:
throw UnsupportedError('Browser $browser not supported.');
}
throw UnsupportedError('Browser $browser not supported.'); // dead code; remove with null safety migration
}
/// Converts [browserName] string to [Browser]
......@@ -332,5 +331,5 @@ Browser _browserNameToEnum(String browserName) {
case 'ios-safari': return Browser.iosSafari;
case 'safari': return Browser.safari;
}
throw UnsupportedError('Browser $browserName not supported');
throw UnsupportedError('Browser $browserName not supported'); // dead code; remove with null safety migration
}
......@@ -348,7 +348,6 @@ List<Map<String, Object?>> _extractPlatformMaps(List<Plugin> plugins, String typ
/// [project] is using.
AndroidEmbeddingVersion _getAndroidEmbeddingVersion(FlutterProject project) {
assert(project.android != null);
return project.android.getEmbeddingVersion();
}
......@@ -415,7 +414,6 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
templateContent = _androidPluginRegistryTemplateNewEmbedding;
break;
case AndroidEmbeddingVersion.v1:
default:
globals.printError(
'This app is using a deprecated version of the Android embedding.\n'
'To avoid unexpected runtime failures, or future build failures, try to migrate this '
......
......@@ -598,8 +598,6 @@ String xcodeBuildActionToString(XcodeBuildAction action) {
return 'build';
case XcodeBuildAction.archive:
return 'archive';
default:
throw UnsupportedError('Unknown Xcode build action');
}
}
......
......@@ -204,7 +204,20 @@ class MDnsObservatoryDiscovery {
'See https://github.com/flutter/flutter/issues/46698 for details.'
);
break;
default:
case TargetPlatform.android:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
case TargetPlatform.darwin:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
case TargetPlatform.windows_x64:
_logger.printTrace('No interface with an ipv4 link local address was found.');
break;
}
......
......@@ -1467,9 +1467,19 @@ Future<String> getMissingPackageHintForPlatform(TargetPlatform platform) async {
return 'Is your project missing an $manifestPath?\nConsider running "flutter create ." to create one.';
case TargetPlatform.ios:
return 'Is your project missing an ios/Runner/Info.plist?\nConsider running "flutter create ." to create one.';
default:
case TargetPlatform.android:
case TargetPlatform.darwin:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
case TargetPlatform.windows_x64:
return null;
}
return null; // dead code, remove after null safety migration
}
/// Redirects terminal commands to the correct resident runner methods.
......
......@@ -91,10 +91,8 @@ class FlutterCommandResult {
return 'fail';
case ExitStatus.killed:
return 'killed';
default:
assert(false);
return null;
}
return null; // dead code, remove with null safety migration
}
}
......
......@@ -47,7 +47,17 @@ Future<String> sharedSkSlWriter(Device device, Map<String, Object> data, {
case TargetPlatform.android_x86:
targetPlatform = TargetPlatform.android;
break;
default:
case TargetPlatform.android:
case TargetPlatform.darwin:
case TargetPlatform.ios:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_uwp_x64:
case TargetPlatform.windows_x64:
break;
}
final Map<String, Object> manifest = <String, Object>{
......
......@@ -84,7 +84,8 @@ void main() {
androidProject
..pluginRegistrantHost = androidDirectory.childDirectory('app')
..hostAppGradleRoot = androidDirectory
..exists = false;
..exists = false
..embeddingVersion = AndroidEmbeddingVersion.v2;
webProject = FakeWebProject();
flutterProject.web = webProject;
......@@ -922,7 +923,6 @@ dependencies:
testUsingContext('Does not throw when AndroidManifest.xml is not found', () async {
final File manifest = fs.file('AndroidManifest.xml');
androidProject.appManifestFile = manifest;
await injectPlugins(flutterProject, androidPlatform: true);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
......
......@@ -125,7 +125,7 @@ class WebCallbackManager implements CallbackManager {
'message': Response.webDriverCommand(data: data).toJson(),
};
break;
default:
case WebDriverCommandType.ack:
throw UnimplementedError('${command.type} is not implemented');
}
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment