start method
Implementation
Future<void> start() async {
_startedAt = DateTime.now();
_status('Watching ${vmServiceOutFile.path} for the VM service address...');
if (!vmServiceOutFile.parent.existsSync()) {
vmServiceOutFile.parent.createSync(recursive: true);
}
// A file left over from an earlier `flutter run` points at a port that
// died with it. Connecting then fails in a way that looks like a bug in
// the app rather than a stale address, so say so up front.
if (vmServiceOutFile.existsSync() && vmServiceOutFile.lastModifiedSync().isBefore(_startedAt)) {
_status(
'${vmServiceOutFile.path} is left over from an earlier run, so its address is probably dead. '
'Waiting for your app to rewrite it.',
);
}
_armHint();
unawaited(_tryConnectFromFile());
_watchSub = vmServiceOutFile.parent.watch(events: FileSystemEvent.all).listen((FileSystemEvent event) {
if (event.path == vmServiceOutFile.path) {
unawaited(_tryConnectFromFile());
}
});
}