Closes https://github.com/flutter/flutter/issues/162041.
I also converted the `.sh` and `.bat` files (largely) to Dart, mostly
because I don't know enough Windows XP command prompt in order to make
the change safely. They should still run the same from the CI
bootstrapping, but most of the logic is now Dart code.
Will send a separate PR to update the `flutter/tests` PR template.
/cc @johnmccutchan @Piinks