Send RPC request to switch assets directory on hot reload. (#12872)
* Send RPC request to switch assets directory on hot reload. This is needed to pick up updated assets that are expected to be picked up on hot reload. * Assert assets directory is not null. * Better multiple future wait * Add type annotation
This commit is contained in:
committed by
GitHub
parent
885e96914d
commit
8da5af55c5
@@ -141,6 +141,15 @@ class FlutterDevice {
|
||||
return reports;
|
||||
}
|
||||
|
||||
Future<Null> resetAssetDirectory() async {
|
||||
final Uri deviceAssetsDirectoryUri = devFS.baseUri.resolveUri(
|
||||
fs.path.toUri(getAssetBuildDirectory()));
|
||||
assert(deviceAssetsDirectoryUri != null);
|
||||
await Future.wait(views.map(
|
||||
(FlutterView view) => view.setAssetDirectory(deviceAssetsDirectoryUri)
|
||||
));
|
||||
}
|
||||
|
||||
// Lists program elements changed in the most recent reload that have not
|
||||
// since executed.
|
||||
Future<List<ProgramElement>> unusedChangesInLastReload() async {
|
||||
|
||||
@@ -516,6 +516,8 @@ class HotRunner extends ResidentRunner {
|
||||
int countExpectedReports = 0;
|
||||
for (FlutterDevice device in flutterDevices) {
|
||||
// List has one report per Flutter view.
|
||||
await device.resetAssetDirectory();
|
||||
|
||||
final List<Future<Map<String, dynamic>>> reports = device.reloadSources(
|
||||
entryPath,
|
||||
pause: pause
|
||||
|
||||
@@ -1318,6 +1318,15 @@ class FlutterView extends ServiceObject {
|
||||
await subscription.cancel();
|
||||
}
|
||||
|
||||
Future<Null> setAssetDirectory(Uri assetsDirectory) async {
|
||||
assert(assetsDirectory != null);
|
||||
await owner.vmService.vm.invokeRpc('_flutter.setAssetBundlePath',
|
||||
params: <String, dynamic>{
|
||||
'viewId': id,
|
||||
'assetDirectory': assetsDirectory.toFilePath(windows: false)
|
||||
});
|
||||
}
|
||||
|
||||
bool get hasIsolate => _uiIsolate != null;
|
||||
|
||||
Future<Null> flushUIThreadTasks() async {
|
||||
|
||||
Reference in New Issue
Block a user