Future generateIcons()

in tool/icons/update_icons.dart [122:150]


Future<void> generateIcons(String appFolder) async {
  final Process proc = await Process.start(
      'flutter', <String>['run', '-d', 'flutter-tester'],
      workingDirectory: appFolder);
  // Errors in the Flutter app will not set the exit code, so we need to
  // watch stdout/stderr for errors.
  bool hasError = false;
  proc.stdout
      .transform(utf8.decoder)
      .transform(const LineSplitter())
      .listen((String line) {
    if (line.contains('ERROR:')) {
      hasError = true;
    }
    stdout.writeln(line);
  });
  proc.stderr
      .transform(utf8.decoder)
      .transform(const LineSplitter())
      .listen((String line) {
    hasError = true;
    stderr.writeln(line);
  });

  final int exitCode = await proc.exitCode;
  if (exitCode != 0 || hasError) {
    throw 'Process exited with error ($exitCode)';
  }
}