Do not throw if a hot reload is attempted when all Flutter instances on the device have been stopped (#11504)

This can happen if an Android host app has been paused but its process is still running
This commit is contained in:
Jason Simmons 2017-08-03 13:09:10 -07:00 committed by GitHub
parent 8ee902c04b
commit ffe5851eb7

View file

@ -467,16 +467,19 @@ class HotRunner extends ResidentRunner {
final String entryPath = fs.path.relative(mainPath, from: projectRootPath); final String entryPath = fs.path.relative(mainPath, from: projectRootPath);
if (benchmarkMode) if (benchmarkMode)
vmReloadTimer.start(); vmReloadTimer.start();
Map<String, dynamic> reloadReport; final List<Future<Map<String, dynamic>>> reloadReportFutures = <Future<Map<String, dynamic>>>[];
final List<Future<Map<String, dynamic>>> reloadReports = <Future<Map<String, dynamic>>>[];
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
final List<Future<Map<String, dynamic>>> reports = device.reloadSources( final List<Future<Map<String, dynamic>>> reports = device.reloadSources(
entryPath, entryPath,
pause: pause pause: pause
); );
reloadReports.addAll(reports); reloadReportFutures.addAll(reports);
} }
reloadReport = (await Future.wait(reloadReports)).first; if (reloadReportFutures.isEmpty) {
printError('Unable to hot reload. No instance of Flutter is currently running.');
return new OperationResult(1, 'No instances running');
}
final Map<String, dynamic> reloadReport = (await Future.wait(reloadReportFutures)).first;
if (!validateReloadReport(reloadReport)) { if (!validateReloadReport(reloadReport)) {
// Reload failed. // Reload failed.