Unverified Commit 9d9836f0 authored by Devon Carew's avatar Devon Carew Committed by GitHub

adjust declared types to work with dart 2 typing at runtime (#19007)

* adjust declared types to work with dart 2 typing at runtime

* review comments

* update packages/flutter_tools/lib/src/ios/simulators.dart
parent 77a528c4
...@@ -150,7 +150,8 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -150,7 +150,8 @@ class AndroidStudio implements Comparable<AndroidStudio> {
final Iterable<Directory> directories = fs final Iterable<Directory> directories = fs
.directory(path) .directory(path)
.listSync() .listSync()
.where((FileSystemEntity e) => e is Directory); .where((FileSystemEntity e) => e is Directory)
.cast<Directory>();
for (Directory directory in directories) { for (Directory directory in directories) {
final String name = directory.basename; final String name = directory.basename;
// An exact match, or something like 'Android Studio 3.0 Preview.app'. // An exact match, or something like 'Android Studio 3.0 Preview.app'.
......
...@@ -10,6 +10,7 @@ import 'package:yaml/yaml.dart'; ...@@ -10,6 +10,7 @@ import 'package:yaml/yaml.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/platform.dart'; import 'base/platform.dart';
import 'base/utils.dart';
import 'build_info.dart'; import 'build_info.dart';
import 'cache.dart'; import 'cache.dart';
import 'dart/package_map.dart'; import 'dart/package_map.dart';
...@@ -268,20 +269,21 @@ Map<String, dynamic> _readMaterialFontsManifest() { ...@@ -268,20 +269,21 @@ Map<String, dynamic> _readMaterialFontsManifest() {
final String fontsPath = fs.path.join(fs.path.absolute(Cache.flutterRoot), final String fontsPath = fs.path.join(fs.path.absolute(Cache.flutterRoot),
'packages', 'flutter_tools', 'schema', 'material_fonts.yaml'); 'packages', 'flutter_tools', 'schema', 'material_fonts.yaml');
return loadYaml(fs.file(fontsPath).readAsStringSync()); return castStringKeyedMap(loadYaml(fs.file(fontsPath).readAsStringSync()));
} }
final Map<String, dynamic> _materialFontsManifest = _readMaterialFontsManifest(); final Map<String, dynamic> _materialFontsManifest = _readMaterialFontsManifest();
List<Map<String, dynamic>> _getMaterialFonts(String fontSet) { List<Map<String, dynamic>> _getMaterialFonts(String fontSet) {
return _materialFontsManifest[fontSet]; final List<dynamic> fontsList = _materialFontsManifest[fontSet];
return fontsList?.map<Map<String, dynamic>>(castStringKeyedMap)?.toList();
} }
List<_Asset> _getMaterialAssets(String fontSet) { List<_Asset> _getMaterialAssets(String fontSet) {
final List<_Asset> result = <_Asset>[]; final List<_Asset> result = <_Asset>[];
for (Map<String, dynamic> family in _getMaterialFonts(fontSet)) { for (Map<String, dynamic> family in _getMaterialFonts(fontSet)) {
for (Map<String, dynamic> font in family['fonts']) { for (Map<dynamic, dynamic> font in family['fonts']) {
final Uri entryUri = fs.path.toUri(font['asset']); final Uri entryUri = fs.path.toUri(font['asset']);
result.add(new _Asset( result.add(new _Asset(
baseDir: fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'), baseDir: fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
......
...@@ -231,6 +231,13 @@ class Uuid { ...@@ -231,6 +231,13 @@ class Uuid {
value.toRadixString(16).padLeft(count, '0'); value.toRadixString(16).padLeft(count, '0');
} }
/// Given a data structure which is a Map of String to dynamic values, return
/// the same structure (`Map<String, dynamic>`) with the correct runtime types.
Map<String, dynamic> castStringKeyedMap(dynamic untyped) {
final Map<dynamic, dynamic> map = untyped;
return map.cast<String, dynamic>();
}
Clock get clock => context[Clock]; Clock get clock => context[Clock];
typedef Future<Null> AsyncCallback(); typedef Future<Null> AsyncCallback();
......
...@@ -143,8 +143,12 @@ class Daemon { ...@@ -143,8 +143,12 @@ class Daemon {
throw 'no domain for method: $method'; throw 'no domain for method: $method';
_domainMap[prefix].handleCommand(name, id, request['params'] ?? const <String, dynamic>{}); _domainMap[prefix].handleCommand(name, id, request['params'] ?? const <String, dynamic>{});
} catch (error) { } catch (error, trace) {
_send(<String, dynamic>{'id': id, 'error': _toJsonable(error)}); _send(<String, dynamic>{
'id': id,
'error': _toJsonable(error),
'trace': '$trace',
});
} }
} }
...@@ -184,14 +188,18 @@ abstract class Domain { ...@@ -184,14 +188,18 @@ abstract class Domain {
if (_handlers.containsKey(command)) if (_handlers.containsKey(command))
return _handlers[command](args); return _handlers[command](args);
throw 'command not understood: $name.$command'; throw 'command not understood: $name.$command';
}).then<Null>((dynamic result) { }).then<dynamic>((dynamic result) {
if (result == null) { if (result == null) {
_send(<String, dynamic>{'id': id}); _send(<String, dynamic>{'id': id});
} else { } else {
_send(<String, dynamic>{'id': id, 'result': _toJsonable(result)}); _send(<String, dynamic>{'id': id, 'result': _toJsonable(result)});
} }
}).catchError((dynamic error, dynamic trace) { }).catchError((dynamic error, dynamic trace) {
_send(<String, dynamic>{'id': id, 'error': _toJsonable(error)}); _send(<String, dynamic>{
'id': id,
'error': _toJsonable(error),
'trace': '$trace',
});
}); });
} }
...@@ -393,7 +401,7 @@ class AppDomain extends Domain { ...@@ -393,7 +401,7 @@ class AppDomain extends Domain {
_sendAppEvent(app, 'started'); _sendAppEvent(app, 'started');
}); });
await app._runInZone(this, () async { await app._runInZone<Null>(this, () async {
try { try {
await runner.run( await runner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -401,8 +409,11 @@ class AppDomain extends Domain { ...@@ -401,8 +409,11 @@ class AppDomain extends Domain {
route: route, route: route,
); );
_sendAppEvent(app, 'stop'); _sendAppEvent(app, 'stop');
} catch (error) { } catch (error, trace) {
_sendAppEvent(app, 'stop', <String, dynamic>{'error': _toJsonable(error)}); _sendAppEvent(app, 'stop', <String, dynamic>{
'error': _toJsonable(error),
'trace': '$trace',
});
} finally { } finally {
fs.currentDirectory = cwd; fs.currentDirectory = cwd;
_apps.remove(app); _apps.remove(app);
...@@ -429,7 +440,7 @@ class AppDomain extends Domain { ...@@ -429,7 +440,7 @@ class AppDomain extends Domain {
if (_inProgressHotReload != null) if (_inProgressHotReload != null)
throw 'hot restart already in progress'; throw 'hot restart already in progress';
_inProgressHotReload = app._runInZone(this, () { _inProgressHotReload = app._runInZone<OperationResult>(this, () {
return app.restart(fullRestart: fullRestart, pauseAfterRestart: pauseAfterRestart); return app.restart(fullRestart: fullRestart, pauseAfterRestart: pauseAfterRestart);
}); });
return _inProgressHotReload.whenComplete(() { return _inProgressHotReload.whenComplete(() {
...@@ -449,7 +460,7 @@ class AppDomain extends Domain { ...@@ -449,7 +460,7 @@ class AppDomain extends Domain {
Future<Map<String, dynamic>> callServiceExtension(Map<String, dynamic> args) async { Future<Map<String, dynamic>> callServiceExtension(Map<String, dynamic> args) async {
final String appId = _getStringArg(args, 'appId', required: true); final String appId = _getStringArg(args, 'appId', required: true);
final String methodName = _getStringArg(args, 'methodName'); final String methodName = _getStringArg(args, 'methodName');
final Map<String, String> params = args['params'] ?? <String, String>{}; final Map<String, dynamic> params = args['params'] == null ? <String, dynamic>{} : castStringKeyedMap(args['params']);
final AppInstance app = _getApp(appId); final AppInstance app = _getApp(appId);
if (app == null) if (app == null)
...@@ -741,10 +752,10 @@ class AppInstance { ...@@ -741,10 +752,10 @@ class AppInstance {
_logger.close(); _logger.close();
} }
dynamic _runInZone(AppDomain domain, dynamic method()) { Future<T> _runInZone<T>(AppDomain domain, dynamic method()) {
_logger ??= new _AppRunLogger(domain, this, parent: logToStdout ? logger : null); _logger ??= new _AppRunLogger(domain, this, parent: logToStdout ? logger : null);
return context.run<dynamic>( return context.run<T>(
body: method, body: method,
overrides: <Type, Generator>{ overrides: <Type, Generator>{
Logger: () => _logger, Logger: () => _logger,
......
...@@ -10,6 +10,7 @@ import '../base/file_system.dart'; ...@@ -10,6 +10,7 @@ import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../base/utils.dart';
import '../globals.dart'; import '../globals.dart';
class AnalysisServer { class AnalysisServer {
...@@ -136,8 +137,10 @@ class AnalysisServer { ...@@ -136,8 +137,10 @@ class AnalysisServer {
void _handleAnalysisIssues(Map<String, dynamic> issueInfo) { void _handleAnalysisIssues(Map<String, dynamic> issueInfo) {
// {"event":"analysis.errors","params":{"file":"/Users/.../lib/main.dart","errors":[]}} // {"event":"analysis.errors","params":{"file":"/Users/.../lib/main.dart","errors":[]}}
final String file = issueInfo['file']; final String file = issueInfo['file'];
final List<AnalysisError> errors = issueInfo['errors'] final List<dynamic> errorsList = issueInfo['errors'];
.map((Map<String, dynamic> json) => new AnalysisError(json)) final List<AnalysisError> errors = errorsList
.map<Map<String, dynamic>>(castStringKeyedMap)
.map<AnalysisError>((Map<String, dynamic> json) => new AnalysisError(json))
.toList(); .toList();
if (!_errorsController.isClosed) if (!_errorsController.isClosed)
_errorsController.add(new FileAnalysisErrors(file, errors)); _errorsController.add(new FileAnalysisErrors(file, errors));
......
...@@ -10,6 +10,7 @@ import 'package:meta/meta.dart'; ...@@ -10,6 +10,7 @@ import 'package:meta/meta.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/utils.dart';
import 'cache.dart'; import 'cache.dart';
import 'globals.dart'; import 'globals.dart';
...@@ -33,13 +34,25 @@ class FlutterManifest { ...@@ -33,13 +34,25 @@ class FlutterManifest {
return _createFromYaml(loadYaml(manifest)); return _createFromYaml(loadYaml(manifest));
} }
static Future<FlutterManifest> _createFromYaml(Object yamlDocument) async { static Future<FlutterManifest> _createFromYaml(dynamic yamlDocument) async {
final FlutterManifest pubspec = new FlutterManifest._(); final FlutterManifest pubspec = new FlutterManifest._();
if (yamlDocument != null && !await _validate(yamlDocument)) if (yamlDocument != null && !await _validate(yamlDocument))
return null; return null;
pubspec._descriptor = yamlDocument ?? <String, dynamic>{}; final Map<dynamic, dynamic> yamlMap = yamlDocument;
pubspec._flutterDescriptor = pubspec._descriptor['flutter'] ?? <String, dynamic>{}; if (yamlMap != null) {
pubspec._descriptor = yamlMap.cast<String, dynamic>();
} else {
pubspec._descriptor = <String, dynamic>{};
}
final Map<dynamic, dynamic> flutterMap = pubspec._descriptor['flutter'];
if (flutterMap != null) {
pubspec._flutterDescriptor = flutterMap.cast<String, dynamic>();
} else {
pubspec._flutterDescriptor = <String, dynamic>{};
}
return pubspec; return pubspec;
} }
...@@ -105,11 +118,22 @@ class FlutterManifest { ...@@ -105,11 +118,22 @@ class FlutterManifest {
bool get isModule => moduleDescriptor != null; bool get isModule => moduleDescriptor != null;
List<Map<String, dynamic>> get fontsDescriptor { List<Map<String, dynamic>> get fontsDescriptor {
return _flutterDescriptor['fonts'] ?? const <Map<String, dynamic>>[]; final List<dynamic> fontList = _flutterDescriptor['fonts'];
return fontList == null
? const <Map<String, dynamic>>[]
: fontList.map<Map<String, dynamic>>(castStringKeyedMap).toList();
} }
List<Uri> get assets { List<Uri> get assets {
return _flutterDescriptor['assets']?.map(Uri.encodeFull)?.map(Uri.parse)?.toList() ?? const <Uri>[]; final List<dynamic> assets = _flutterDescriptor['assets'];
if (assets == null) {
return const <Uri>[];
}
return assets
.cast<String>()
.map<String>(Uri.encodeFull)
?.map<Uri>(Uri.parse)
?.toList();
} }
List<Font> _fonts; List<Font> _fonts;
...@@ -124,8 +148,8 @@ class FlutterManifest { ...@@ -124,8 +148,8 @@ class FlutterManifest {
return <Font>[]; return <Font>[];
final List<Font> fonts = <Font>[]; final List<Font> fonts = <Font>[];
for (Map<String, dynamic> fontFamily in _flutterDescriptor['fonts']) { for (Map<String, dynamic> fontFamily in fontsDescriptor) {
final List<Map<String, dynamic>> fontFiles = fontFamily['fonts']; final List<dynamic> fontFiles = fontFamily['fonts'];
final String familyName = fontFamily['family']; final String familyName = fontFamily['family'];
if (familyName == null) { if (familyName == null) {
printError('Warning: Missing family name for font.', emphasis: true); printError('Warning: Missing family name for font.', emphasis: true);
...@@ -137,7 +161,7 @@ class FlutterManifest { ...@@ -137,7 +161,7 @@ class FlutterManifest {
} }
final List<FontAsset> fontAssets = <FontAsset>[]; final List<FontAsset> fontAssets = <FontAsset>[];
for (Map<String, dynamic> fontFile in fontFiles) { for (Map<dynamic, dynamic> fontFile in fontFiles) {
final String asset = fontFile['asset']; final String asset = fontFile['asset'];
if (asset == null) { if (asset == null) {
printError('Warning: Missing asset in fonts for $familyName', emphasis: true); printError('Warning: Missing asset in fonts for $familyName', emphasis: true);
...@@ -216,7 +240,7 @@ String buildSchemaPath(FileSystem fs) { ...@@ -216,7 +240,7 @@ String buildSchemaPath(FileSystem fs) {
); );
} }
Future<bool> _validate(Object manifest) async { Future<bool> _validate(dynamic manifest) async {
final String schemaPath = buildSchemaPath(fs); final String schemaPath = buildSchemaPath(fs);
final String schemaData = fs.file(schemaPath).readAsStringSync(); final String schemaData = fs.file(schemaPath).readAsStringSync();
......
...@@ -395,7 +395,7 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -395,7 +395,7 @@ Future<XcodeBuildResult> buildXcodeProject({
'-allowProvisioningUpdates', '-allowProvisioningUpdates',
'-allowProvisioningDeviceRegistration', '-allowProvisioningDeviceRegistration',
].contains(buildCommand); ].contains(buildCommand);
}), }).toList(),
workingDirectory: app.appDirectory, workingDirectory: app.appDirectory,
)); ));
......
...@@ -14,6 +14,7 @@ import '../base/io.dart'; ...@@ -14,6 +14,7 @@ import '../base/io.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../bundle.dart' as bundle; import '../bundle.dart' as bundle;
import '../device.dart'; import '../device.dart';
...@@ -95,7 +96,7 @@ class SimControl { ...@@ -95,7 +96,7 @@ class SimControl {
for (String deviceCategory in devicesSection.keys) { for (String deviceCategory in devicesSection.keys) {
final List<dynamic> devicesData = devicesSection[deviceCategory]; final List<dynamic> devicesData = devicesSection[deviceCategory];
for (Map<String, dynamic> data in devicesData.map(_castStringKeyedMap)) { for (Map<String, dynamic> data in devicesData.map<Map<String, dynamic>>(castStringKeyedMap)) {
devices.add(new SimDevice(deviceCategory, data)); devices.add(new SimDevice(deviceCategory, data));
} }
} }
...@@ -103,11 +104,6 @@ class SimControl { ...@@ -103,11 +104,6 @@ class SimControl {
return devices; return devices;
} }
Map<String, dynamic> _castStringKeyedMap(dynamic untyped) {
final Map<dynamic, dynamic> map = untyped;
return map.cast<String, dynamic>();
}
/// Returns all the connected simulator devices. /// Returns all the connected simulator devices.
List<SimDevice> getConnectedDevices() { List<SimDevice> getConnectedDevices() {
return getDevices().where((SimDevice device) => device.isBooted).toList(); return getDevices().where((SimDevice device) => device.isBooted).toList();
...@@ -123,23 +119,23 @@ class SimControl { ...@@ -123,23 +119,23 @@ class SimControl {
]); ]);
} }
Future<Null> install(String deviceId, String appPath) { Future<RunResult> install(String deviceId, String appPath) {
return runCheckedAsync(<String>[_xcrunPath, 'simctl', 'install', deviceId, appPath]); return runCheckedAsync(<String>[_xcrunPath, 'simctl', 'install', deviceId, appPath]);
} }
Future<Null> uninstall(String deviceId, String appId) { Future<RunResult> uninstall(String deviceId, String appId) {
return runCheckedAsync(<String>[_xcrunPath, 'simctl', 'uninstall', deviceId, appId]); return runCheckedAsync(<String>[_xcrunPath, 'simctl', 'uninstall', deviceId, appId]);
} }
Future<Null> launch(String deviceId, String appIdentifier, [List<String> launchArgs]) { Future<RunResult> launch(String deviceId, String appIdentifier, [List<String> launchArgs]) {
final List<String> args = <String>[_xcrunPath, 'simctl', 'launch', deviceId, appIdentifier]; final List<String> args = <String>[_xcrunPath, 'simctl', 'launch', deviceId, appIdentifier];
if (launchArgs != null) if (launchArgs != null)
args.addAll(launchArgs); args.addAll(launchArgs);
return runCheckedAsync(args); return runCheckedAsync(args);
} }
Future<void> takeScreenshot(String deviceId, String outputPath) { Future<void> takeScreenshot(String deviceId, String outputPath) async {
return runCheckedAsync(<String>[_xcrunPath, 'simctl', 'io', deviceId, 'screenshot', outputPath]); await runCheckedAsync(<String>[_xcrunPath, 'simctl', 'io', deviceId, 'screenshot', outputPath]);
} }
} }
...@@ -350,14 +346,14 @@ class IOSSimulator extends Device { ...@@ -350,14 +346,14 @@ class IOSSimulator extends Device {
return criteria.reduce((bool a, bool b) => a && b); return criteria.reduce((bool a, bool b) => a && b);
} }
Future<Null> _setupUpdatedApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath, bool usesTerminalUi) async { Future<void> _setupUpdatedApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath, bool usesTerminalUi) async {
await _sideloadUpdatedAssetsForInstalledApplicationBundle(app, buildInfo, mainPath); await _sideloadUpdatedAssetsForInstalledApplicationBundle(app, buildInfo, mainPath);
if (!await _applicationIsInstalledAndRunning(app)) if (!await _applicationIsInstalledAndRunning(app))
return _buildAndInstallApplicationBundle(app, buildInfo, mainPath, usesTerminalUi); return _buildAndInstallApplicationBundle(app, buildInfo, mainPath, usesTerminalUi);
} }
Future<Null> _buildAndInstallApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath, bool usesTerminalUi) async { Future<void> _buildAndInstallApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath, bool usesTerminalUi) async {
// Step 1: Build the Xcode project. // Step 1: Build the Xcode project.
// The build mode for the simulator is always debug. // The build mode for the simulator is always debug.
...@@ -389,7 +385,7 @@ class IOSSimulator extends Device { ...@@ -389,7 +385,7 @@ class IOSSimulator extends Device {
await SimControl.instance.install(id, fs.path.absolute(bundle.path)); await SimControl.instance.install(id, fs.path.absolute(bundle.path));
} }
Future<Null> _sideloadUpdatedAssetsForInstalledApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath) { Future<void> _sideloadUpdatedAssetsForInstalledApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath) {
// When running in previewDart2 mode, we still need to run compiler to // When running in previewDart2 mode, we still need to run compiler to
// produce kernel file for the application. // produce kernel file for the application.
return bundle.build( return bundle.build(
......
...@@ -388,7 +388,7 @@ class VersionCheckStamp { ...@@ -388,7 +388,7 @@ class VersionCheckStamp {
return const VersionCheckStamp(); return const VersionCheckStamp();
} }
static VersionCheckStamp fromJson(Map<String, String> jsonObject) { static VersionCheckStamp fromJson(Map<String, dynamic> jsonObject) {
DateTime readDateTime(String property) { DateTime readDateTime(String property) {
return jsonObject.containsKey(property) return jsonObject.containsKey(property)
? DateTime.parse(jsonObject[property]) ? DateTime.parse(jsonObject[property])
......
...@@ -17,6 +17,7 @@ import 'package:web_socket_channel/web_socket_channel.dart'; ...@@ -17,6 +17,7 @@ import 'package:web_socket_channel/web_socket_channel.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart' as io; import 'base/io.dart' as io;
import 'base/utils.dart';
import 'globals.dart'; import 'globals.dart';
import 'vmservice_record_replay.dart'; import 'vmservice_record_replay.dart';
...@@ -256,7 +257,10 @@ class VMService { ...@@ -256,7 +257,10 @@ class VMService {
/// Whether our connection to the VM service has been closed; /// Whether our connection to the VM service has been closed;
bool get isClosed => _peer.isClosed; bool get isClosed => _peer.isClosed;
Future<Null> get done => _peer.done;
Future<Null> get done async {
await _peer.done;
}
// Events // Events
Future<Stream<ServiceEvent>> get onDebugEvent => onEvent('Debug'); Future<Stream<ServiceEvent>> get onDebugEvent => onEvent('Debug');
...@@ -284,7 +288,7 @@ class VMService { ...@@ -284,7 +288,7 @@ class VMService {
Map<String, dynamic> params, Map<String, dynamic> params,
) { ) {
return Future.any(<Future<Map<String, dynamic>>>[ return Future.any(<Future<Map<String, dynamic>>>[
_peer.sendRequest(method, params), _peer.sendRequest(method, params).then<Map<String, dynamic>>(castStringKeyedMap),
_connectionError.future, _connectionError.future,
]); ]);
} }
...@@ -334,8 +338,8 @@ class VMService { ...@@ -334,8 +338,8 @@ class VMService {
} }
/// Reloads the VM. /// Reloads the VM.
Future<VM> getVM() { Future<VM> getVM() async {
return _vm.reload(); return await _vm.reload();
} }
Future<Null> waitForViews({int attempts = 5, int attemptSeconds = 1}) async { Future<Null> waitForViews({int attempts = 5, int attemptSeconds = 1}) async {
...@@ -683,7 +687,7 @@ class VM extends ServiceObjectOwner { ...@@ -683,7 +687,7 @@ class VM extends ServiceObjectOwner {
_embedder = map['_embedder']; _embedder = map['_embedder'];
// Remove any isolates which are now dead from the isolate cache. // Remove any isolates which are now dead from the isolate cache.
_removeDeadIsolates(map['isolates']); _removeDeadIsolates(map['isolates'].cast<Isolate>());
} }
final Map<String, ServiceObject> _cache = <String,ServiceObject>{}; final Map<String, ServiceObject> _cache = <String,ServiceObject>{};
...@@ -851,7 +855,7 @@ class VM extends ServiceObjectOwner { ...@@ -851,7 +855,7 @@ class VM extends ServiceObjectOwner {
} }
/// Invoke the RPC and return a [ServiceObject] response. /// Invoke the RPC and return a [ServiceObject] response.
Future<ServiceObject> invokeRpc(String method, { Future<T> invokeRpc<T extends ServiceObject>(String method, {
Map<String, dynamic> params = const <String, dynamic>{}, Map<String, dynamic> params = const <String, dynamic>{},
Duration timeout, Duration timeout,
}) async { }) async {
...@@ -922,7 +926,7 @@ class VM extends ServiceObjectOwner { ...@@ -922,7 +926,7 @@ class VM extends ServiceObjectOwner {
Uri packages, Uri packages,
Uri assetsDirectory) { Uri assetsDirectory) {
// TODO(goderbauer): Transfer Uri (instead of file path) when remote end supports it. // TODO(goderbauer): Transfer Uri (instead of file path) when remote end supports it.
return invokeRpc('_flutter.runInView', return invokeRpc<ServiceMap>('_flutter.runInView',
params: <String, dynamic> { params: <String, dynamic> {
'viewId': viewId, 'viewId': viewId,
'mainScript': main.toFilePath(windows: false), 'mainScript': main.toFilePath(windows: false),
...@@ -1324,7 +1328,7 @@ class Isolate extends ServiceObjectOwner { ...@@ -1324,7 +1328,7 @@ class Isolate extends ServiceObjectOwner {
} }
Future<String> flutterPlatformOverride([String platform]) async { Future<String> flutterPlatformOverride([String platform]) async {
final Map<String, String> result = await invokeFlutterExtensionRpcRaw( final Map<String, dynamic> result = await invokeFlutterExtensionRpcRaw(
'ext.flutter.platformOverride', 'ext.flutter.platformOverride',
params: platform != null ? <String, dynamic>{ 'value': platform } : <String, String>{}, params: platform != null ? <String, dynamic>{ 'value': platform } : <String, String>{},
timeout: const Duration(seconds: 5), timeout: const Duration(seconds: 5),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment