[flutter_plugin_tools] Work around banner in drive-examples (#4142)

* [flutter_plugin_tools] Work around banner in drive-examples

Strip off any unexpected output before parsing `flutter devices
--machine` output. Works around a bug in the Flutter tool that can
result in banners being printed in `--machine` mode.

Fixes https://github.com/flutter/flutter/issues/86052
This commit is contained in:
stuartmorgan
2021-07-07 20:02:35 -07:00
committed by GitHub
parent d2bac9116b
commit a63c0eb59f
3 changed files with 44 additions and 3 deletions

View File

@ -208,9 +208,14 @@ class DriveExamplesCommand extends PackageLoopingCommand {
return deviceIds;
}
String output = result.stdout as String;
// --machine doesn't currently prevent the tool from printing banners;
// see https://github.com/flutter/flutter/issues/86055. This workaround
// can be removed once that is fixed.
output = output.substring(output.indexOf('['));
final List<Map<String, dynamic>> devices =
(jsonDecode(result.stdout as String) as List<dynamic>)
.cast<Map<String, dynamic>>();
(jsonDecode(output) as List<dynamic>).cast<Map<String, dynamic>>();
for (final Map<String, dynamic> deviceInfo in devices) {
final String targetPlatform =
(deviceInfo['targetPlatform'] as String?) ?? '';