[flutter_tools] dont require a device for screenshot type skia/rasterizer (#80153)

This commit is contained in:
Jonah Williams
2021-04-09 16:59:02 -07:00
committed by GitHub
parent 645432ac41
commit 7533c47465
3 changed files with 75 additions and 41 deletions

View File

@@ -65,9 +65,13 @@ class ScreenshotCommand extends FlutterCommand {
Device device;
static void validateOptions(String screenshotType, Device device, String observatoryUri) {
Future<void> _validateOptions(String screenshotType, String observatoryUri) async {
switch (screenshotType) {
case _kDeviceType:
if (observatoryUri != null) {
throwToolExit('Observatory URI cannot be provided for screenshot type $screenshotType');
}
device = await findTargetDevice();
if (device == null) {
throwToolExit('Must have a connected device for screenshot type $screenshotType');
}
@@ -87,8 +91,7 @@ class ScreenshotCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> verifyThenRunCommand(String commandPath) async {
device = await findTargetDevice();
validateOptions(stringArg(_kType), device, stringArg(_kObservatoryUri));
await _validateOptions(stringArg(_kType), stringArg(_kObservatoryUri));
return super.verifyThenRunCommand(commandPath);
}