Unverified Commit 6e950672 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] Fix _CastError in HotRunner._resetDirtyAssets (#108771)

parent 965912d8
...@@ -12,6 +12,7 @@ import 'context.dart'; ...@@ -12,6 +12,7 @@ import 'context.dart';
import 'io.dart' as io; import 'io.dart' as io;
import 'logger.dart'; import 'logger.dart';
// TODO(fujino): This should be direct injected, rather than mutable global state.
@visibleForTesting @visibleForTesting
Future<dds.DartDevelopmentService> Function( Future<dds.DartDevelopmentService> Function(
Uri remoteVmServiceUri, { Uri remoteVmServiceUri, {
......
...@@ -123,7 +123,7 @@ class _DaemonServer { ...@@ -123,7 +123,7 @@ class _DaemonServer {
// We have to listen to socket.done. Otherwise when the connection is // We have to listen to socket.done. Otherwise when the connection is
// reset, we will receive an uncatchable exception. // reset, we will receive an uncatchable exception.
// https://github.com/dart-lang/sdk/issues/25518 // https://github.com/dart-lang/sdk/issues/25518
final Future<void> socketDone = socket.done.catchError((dynamic error, StackTrace stackTrace) { final Future<void> socketDone = socket.done.catchError((Object error, StackTrace stackTrace) {
logger!.printError('Socket error: $error'); logger!.printError('Socket error: $error');
logger!.printTrace('$stackTrace'); logger!.printTrace('$stackTrace');
}); });
...@@ -145,8 +145,8 @@ class _DaemonServer { ...@@ -145,8 +145,8 @@ class _DaemonServer {
} }
} }
typedef CommandHandler = Future<dynamic>? Function(Map<String, dynamic> args); typedef CommandHandler = Future<Object?>? Function(Map<String, Object?> args);
typedef CommandHandlerWithBinary = Future<dynamic> Function(Map<String, dynamic> args, Stream<List<int>>? binary); typedef CommandHandlerWithBinary = Future<Object?> Function(Map<String, Object?> args, Stream<List<int>>? binary);
class Daemon { class Daemon {
Daemon( Daemon(
...@@ -221,7 +221,7 @@ class Daemon { ...@@ -221,7 +221,7 @@ class Daemon {
throw DaemonException('no domain for method: $method'); throw DaemonException('no domain for method: $method');
} }
_domainMap[prefix]!.handleCommand(name, id, castStringKeyedMap(request.data['params']) ?? const <String, dynamic>{}, request.binary); _domainMap[prefix]!.handleCommand(name, id, castStringKeyedMap(request.data['params']) ?? const <String, Object?>{}, request.binary);
} on Exception catch (error, trace) { } on Exception catch (error, trace) {
connection.sendErrorResponse(id, _toJsonable(error), trace); connection.sendErrorResponse(id, _toJsonable(error), trace);
} }
...@@ -268,52 +268,53 @@ abstract class Domain { ...@@ -268,52 +268,53 @@ abstract class Domain {
@override @override
String toString() => name; String toString() => name;
void handleCommand(String command, Object id, Map<String, dynamic> args, Stream<List<int>>? binary) { void handleCommand(String command, Object id, Map<String, Object?> args, Stream<List<int>>? binary) {
Future<dynamic>.sync(() { Future<Object?>.sync(() {
if (_handlers.containsKey(command)) { if (_handlers.containsKey(command)) {
return _handlers[command]!(args); return _handlers[command]!(args);
} else if (_handlersWithBinary.containsKey(command)) { } else if (_handlersWithBinary.containsKey(command)) {
return _handlersWithBinary[command]!(args, binary); return _handlersWithBinary[command]!(args, binary);
} }
throw DaemonException('command not understood: $name.$command'); throw DaemonException('command not understood: $name.$command');
}).then<dynamic>((dynamic result) { }).then<Object?>((Object? result) {
daemon.connection.sendResponse(id, _toJsonable(result)); daemon.connection.sendResponse(id, _toJsonable(result));
return null;
}).catchError((Object error, StackTrace stackTrace) { }).catchError((Object error, StackTrace stackTrace) {
daemon.connection.sendErrorResponse(id, _toJsonable(error), stackTrace); daemon.connection.sendErrorResponse(id, _toJsonable(error), stackTrace);
}); });
} }
void sendEvent(String name, [ dynamic args, List<int>? binary ]) { void sendEvent(String name, [ Object? args, List<int>? binary ]) {
daemon.connection.sendEvent(name, _toJsonable(args), binary); daemon.connection.sendEvent(name, _toJsonable(args), binary);
} }
String? _getStringArg(Map<String, dynamic> args, String name, { bool required = false }) { String? _getStringArg(Map<String, Object?> args, String name, { bool required = false }) {
if (required && !args.containsKey(name)) { if (required && !args.containsKey(name)) {
throw DaemonException('$name is required'); throw DaemonException('$name is required');
} }
final dynamic val = args[name]; final Object? val = args[name];
if (val != null && val is! String) { if (val != null && val is! String) {
throw DaemonException('$name is not a String'); throw DaemonException('$name is not a String');
} }
return val as String?; return val as String?;
} }
bool? _getBoolArg(Map<String, dynamic> args, String name, { bool required = false }) { bool? _getBoolArg(Map<String, Object?> args, String name, { bool required = false }) {
if (required && !args.containsKey(name)) { if (required && !args.containsKey(name)) {
throw DaemonException('$name is required'); throw DaemonException('$name is required');
} }
final dynamic val = args[name]; final Object? val = args[name];
if (val != null && val is! bool) { if (val != null && val is! bool) {
throw DaemonException('$name is not a bool'); throw DaemonException('$name is not a bool');
} }
return val as bool?; return val as bool?;
} }
int? _getIntArg(Map<String, dynamic> args, String name, { bool required = false }) { int? _getIntArg(Map<String, Object?> args, String name, { bool required = false }) {
if (required && !args.containsKey(name)) { if (required && !args.containsKey(name)) {
throw DaemonException('$name is required'); throw DaemonException('$name is required');
} }
final dynamic val = args[name]; final Object? val = args[name];
if (val != null && val is! int) { if (val != null && val is! int) {
throw DaemonException('$name is not an int'); throw DaemonException('$name is not an int');
} }
...@@ -334,7 +335,7 @@ class DaemonDomain extends Domain { ...@@ -334,7 +335,7 @@ class DaemonDomain extends Domain {
sendEvent( sendEvent(
'daemon.connected', 'daemon.connected',
<String, dynamic>{ <String, Object?>{
'version': protocolVersion, 'version': protocolVersion,
'pid': pid, 'pid': pid,
}, },
...@@ -357,13 +358,13 @@ class DaemonDomain extends Domain { ...@@ -357,13 +358,13 @@ class DaemonDomain extends Domain {
} }
} else { } else {
if (message.stackTrace != null) { if (message.stackTrace != null) {
sendEvent('daemon.logMessage', <String, dynamic>{ sendEvent('daemon.logMessage', <String, Object?>{
'level': message.level, 'level': message.level,
'message': message.message, 'message': message.message,
'stackTrace': message.stackTrace.toString(), 'stackTrace': message.stackTrace.toString(),
}); });
} else { } else {
sendEvent('daemon.logMessage', <String, dynamic>{ sendEvent('daemon.logMessage', <String, Object?>{
'level': message.level, 'level': message.level,
'message': message.message, 'message': message.message,
}); });
...@@ -374,7 +375,7 @@ class DaemonDomain extends Domain { ...@@ -374,7 +375,7 @@ class DaemonDomain extends Domain {
StreamSubscription<LogMessage>? _subscription; StreamSubscription<LogMessage>? _subscription;
Future<String> version(Map<String, dynamic> args) { Future<String> version(Map<String, Object?> args) {
return Future<String>.value(protocolVersion); return Future<String>.value(protocolVersion);
} }
...@@ -384,16 +385,16 @@ class DaemonDomain extends Domain { ...@@ -384,16 +385,16 @@ class DaemonDomain extends Domain {
/// --web-allow-expose-url switch. The client may return the same URL back if /// --web-allow-expose-url switch. The client may return the same URL back if
/// tunnelling is not required for a given URL. /// tunnelling is not required for a given URL.
Future<String> exposeUrl(String url) async { Future<String> exposeUrl(String url) async {
final dynamic res = await daemon.connection.sendRequest('app.exposeUrl', <String, String>{'url': url}); final Object? res = await daemon.connection.sendRequest('app.exposeUrl', <String, String>{'url': url});
if (res is Map<String, dynamic> && res['url'] is String) { if (res is Map<String, Object?> && res['url'] is String) {
return res['url'] as String; return res['url']! as String;
} else { } else {
globals.printError('Invalid response to exposeUrl - params should include a String url field'); globals.printError('Invalid response to exposeUrl - params should include a String url field');
return url; return url;
} }
} }
Future<void> shutdown(Map<String, dynamic> args) { Future<void> shutdown(Map<String, Object?> args) {
Timer.run(daemon.shutdown); Timer.run(daemon.shutdown);
return Future<void>.value(); return Future<void>.value();
} }
...@@ -408,7 +409,7 @@ class DaemonDomain extends Domain { ...@@ -408,7 +409,7 @@ class DaemonDomain extends Domain {
/// This does not filter based on the current workflow restrictions, such /// This does not filter based on the current workflow restrictions, such
/// as whether command line tools are installed or whether the host platform /// as whether command line tools are installed or whether the host platform
/// is correct. /// is correct.
Future<Map<String, Object>> getSupportedPlatforms(Map<String, dynamic> args) async { Future<Map<String, Object>> getSupportedPlatforms(Map<String, Object?> args) async {
final String? projectRoot = _getStringArg(args, 'projectRoot', required: true); final String? projectRoot = _getStringArg(args, 'projectRoot', required: true);
final List<String> result = <String>[]; final List<String> result = <String>[];
try { try {
...@@ -442,7 +443,7 @@ class DaemonDomain extends Domain { ...@@ -442,7 +443,7 @@ class DaemonDomain extends Domain {
'platforms': result, 'platforms': result,
}; };
} on Exception catch (err, stackTrace) { } on Exception catch (err, stackTrace) {
sendEvent('log', <String, dynamic>{ sendEvent('log', <String, Object?>{
'log': 'Failed to parse project metadata', 'log': 'Failed to parse project metadata',
'stackTrace': stackTrace.toString(), 'stackTrace': stackTrace.toString(),
'error': true, 'error': true,
...@@ -604,7 +605,7 @@ class AppDomain extends Domain { ...@@ -604,7 +605,7 @@ class AppDomain extends Domain {
logger.domain = this; logger.domain = this;
logger.app = app; logger.app = app;
_sendAppEvent(app, 'start', <String, dynamic>{ _sendAppEvent(app, 'start', <String, Object?>{
'deviceId': device.id, 'deviceId': device.id,
'directory': projectDirectory, 'directory': projectDirectory,
'supportsRestart': isRestartSupported(enableHotReload, device), 'supportsRestart': isRestartSupported(enableHotReload, device),
...@@ -619,7 +620,7 @@ class AppDomain extends Domain { ...@@ -619,7 +620,7 @@ class AppDomain extends Domain {
// As it just writes to stdout. // As it just writes to stdout.
unawaited(connectionInfoCompleter.future.then<void>( unawaited(connectionInfoCompleter.future.then<void>(
(DebugConnectionInfo info) { (DebugConnectionInfo info) {
final Map<String, dynamic> params = <String, dynamic>{ final Map<String, Object?> params = <String, Object?>{
// The web vmservice proxy does not have an http address. // The web vmservice proxy does not have an http address.
'port': info.httpUri?.port ?? info.wsUri!.port, 'port': info.httpUri?.port ?? info.wsUri!.port,
'wsUri': info.wsUri.toString(), 'wsUri': info.wsUri.toString(),
...@@ -646,7 +647,7 @@ class AppDomain extends Domain { ...@@ -646,7 +647,7 @@ class AppDomain extends Domain {
); );
_sendAppEvent(app, 'stop'); _sendAppEvent(app, 'stop');
} on Exception catch (error, trace) { } on Exception catch (error, trace) {
_sendAppEvent(app, 'stop', <String, dynamic>{ _sendAppEvent(app, 'stop', <String, Object?>{
'error': _toJsonable(error), 'error': _toJsonable(error),
'trace': '$trace', 'trace': '$trace',
}); });
...@@ -665,7 +666,7 @@ class AppDomain extends Domain { ...@@ -665,7 +666,7 @@ class AppDomain extends Domain {
final int _hotReloadDebounceDurationMs = 50; final int _hotReloadDebounceDurationMs = 50;
Future<OperationResult>? restart(Map<String, dynamic> args) async { Future<OperationResult>? restart(Map<String, Object?> args) async {
final String? appId = _getStringArg(args, 'appId', required: true); final String? appId = _getStringArg(args, 'appId', required: true);
final bool fullRestart = _getBoolArg(args, 'fullRestart') ?? false; final bool fullRestart = _getBoolArg(args, 'fullRestart') ?? false;
final bool pauseAfterRestart = _getBoolArg(args, 'pause') ?? false; final bool pauseAfterRestart = _getBoolArg(args, 'pause') ?? false;
...@@ -727,18 +728,18 @@ class AppDomain extends Domain { ...@@ -727,18 +728,18 @@ class AppDomain extends Domain {
/// "type":"_extensionType", /// "type":"_extensionType",
/// "method":"ext.flutter.platformOverride" /// "method":"ext.flutter.platformOverride"
/// } /// }
Future<Map<String, dynamic>> callServiceExtension(Map<String, dynamic> args) async { Future<Map<String, Object?>> callServiceExtension(Map<String, Object?> 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, dynamic>? params = args['params'] == null ? <String, dynamic>{} : castStringKeyedMap(args['params']); final Map<String, Object?>? params = args['params'] == null ? <String, Object?>{} : castStringKeyedMap(args['params']);
final AppInstance? app = _getApp(appId); final AppInstance? app = _getApp(appId);
if (app == null) { if (app == null) {
throw DaemonException("app '$appId' not found"); throw DaemonException("app '$appId' not found");
} }
final FlutterDevice device = app.runner!.flutterDevices.first!; final FlutterDevice device = app.runner!.flutterDevices.first;
final List<FlutterView> views = await device.vmService!.getFlutterViews(); final List<FlutterView> views = await device.vmService!.getFlutterViews();
final Map<String, dynamic>? result = await device final Map<String, Object?>? result = await device
.vmService! .vmService!
.invokeFlutterExtensionRpcRaw( .invokeFlutterExtensionRpcRaw(
methodName, methodName,
...@@ -752,13 +753,13 @@ class AppDomain extends Domain { ...@@ -752,13 +753,13 @@ class AppDomain extends Domain {
if (result.containsKey('error')) { if (result.containsKey('error')) {
// ignore: only_throw_errors // ignore: only_throw_errors
throw result['error']! as Object; throw result['error']!;
} }
return result; return result;
} }
Future<bool> stop(Map<String, dynamic> args) async { Future<bool> stop(Map<String, Object?> args) async {
final String? appId = _getStringArg(args, 'appId', required: true); final String? appId = _getStringArg(args, 'appId', required: true);
final AppInstance? app = _getApp(appId); final AppInstance? app = _getApp(appId);
...@@ -768,8 +769,8 @@ class AppDomain extends Domain { ...@@ -768,8 +769,8 @@ class AppDomain extends Domain {
return app.stop().then<bool>( return app.stop().then<bool>(
(void value) => true, (void value) => true,
onError: (dynamic error, StackTrace stack) { onError: (Object? error, StackTrace stack) {
_sendAppEvent(app, 'log', <String, dynamic>{'log': '$error', 'error': true}); _sendAppEvent(app, 'log', <String, Object?>{'log': '$error', 'error': true});
app.closeLogger(); app.closeLogger();
_apps.remove(app); _apps.remove(app);
return false; return false;
...@@ -777,7 +778,7 @@ class AppDomain extends Domain { ...@@ -777,7 +778,7 @@ class AppDomain extends Domain {
); );
} }
Future<bool> detach(Map<String, dynamic> args) async { Future<bool> detach(Map<String, Object?> args) async {
final String? appId = _getStringArg(args, 'appId', required: true); final String? appId = _getStringArg(args, 'appId', required: true);
final AppInstance? app = _getApp(appId); final AppInstance? app = _getApp(appId);
...@@ -787,8 +788,8 @@ class AppDomain extends Domain { ...@@ -787,8 +788,8 @@ class AppDomain extends Domain {
return app.detach().then<bool>( return app.detach().then<bool>(
(void value) => true, (void value) => true,
onError: (dynamic error, StackTrace stack) { onError: (Object? error, StackTrace stack) {
_sendAppEvent(app, 'log', <String, dynamic>{'log': '$error', 'error': true}); _sendAppEvent(app, 'log', <String, Object?>{'log': '$error', 'error': true});
app.closeLogger(); app.closeLogger();
_apps.remove(app); _apps.remove(app);
return false; return false;
...@@ -805,8 +806,8 @@ class AppDomain extends Domain { ...@@ -805,8 +806,8 @@ class AppDomain extends Domain {
return null; return null;
} }
void _sendAppEvent(AppInstance app, String name, [ Map<String, dynamic>? args ]) { void _sendAppEvent(AppInstance app, String name, [ Map<String, Object?>? args ]) {
sendEvent('app.$name', <String, dynamic>{ sendEvent('app.$name', <String, Object?>{
'appId': app.id, 'appId': app.id,
...?args, ...?args,
}); });
...@@ -876,8 +877,8 @@ class DeviceDomain extends Domain { ...@@ -876,8 +877,8 @@ class DeviceDomain extends Domain {
/// Return a list of the current devices, with each device represented as a map /// Return a list of the current devices, with each device represented as a map
/// of properties (id, name, platform, ...). /// of properties (id, name, platform, ...).
Future<List<Map<String, dynamic>>> getDevices([ Map<String, dynamic>? args ]) async { Future<List<Map<String, Object?>>> getDevices([ Map<String, Object?>? args ]) async {
return <Map<String, dynamic>>[ return <Map<String, Object?>>[
for (final PollingDeviceDiscovery discoverer in _discoverers) for (final PollingDeviceDiscovery discoverer in _discoverers)
for (final Device device in await discoverer.devices) for (final Device device in await discoverer.devices)
await _deviceToMap(device), await _deviceToMap(device),
...@@ -885,8 +886,8 @@ class DeviceDomain extends Domain { ...@@ -885,8 +886,8 @@ class DeviceDomain extends Domain {
} }
/// Return a list of the current devices, discarding existing cache of devices. /// Return a list of the current devices, discarding existing cache of devices.
Future<List<Map<String, dynamic>>> discoverDevices([ Map<String, dynamic>? args ]) async { Future<List<Map<String, Object?>>> discoverDevices([ Map<String, Object?>? args ]) async {
return <Map<String, dynamic>>[ return <Map<String, Object?>>[
for (final PollingDeviceDiscovery discoverer in _discoverers) for (final PollingDeviceDiscovery discoverer in _discoverers)
for (final Device device in await discoverer.discoverDevices()) for (final Device device in await discoverer.discoverDevices())
await _deviceToMap(device), await _deviceToMap(device),
...@@ -894,21 +895,21 @@ class DeviceDomain extends Domain { ...@@ -894,21 +895,21 @@ class DeviceDomain extends Domain {
} }
/// Enable device events. /// Enable device events.
Future<void> enable(Map<String, dynamic> args) async { Future<void> enable(Map<String, Object?> args) async {
for (final PollingDeviceDiscovery discoverer in _discoverers) { for (final PollingDeviceDiscovery discoverer in _discoverers) {
discoverer.startPolling(); discoverer.startPolling();
} }
} }
/// Disable device events. /// Disable device events.
Future<void> disable(Map<String, dynamic> args) async { Future<void> disable(Map<String, Object?> args) async {
for (final PollingDeviceDiscovery discoverer in _discoverers) { for (final PollingDeviceDiscovery discoverer in _discoverers) {
discoverer.stopPolling(); discoverer.stopPolling();
} }
} }
/// Forward a host port to a device port. /// Forward a host port to a device port.
Future<Map<String, dynamic>> forward(Map<String, dynamic> args) async { Future<Map<String, Object?>> forward(Map<String, Object?> args) async {
final String? deviceId = _getStringArg(args, 'deviceId', required: true); final String? deviceId = _getStringArg(args, 'deviceId', required: true);
final int devicePort = _getIntArg(args, 'devicePort', required: true)!; final int devicePort = _getIntArg(args, 'devicePort', required: true)!;
int? hostPort = _getIntArg(args, 'hostPort'); int? hostPort = _getIntArg(args, 'hostPort');
...@@ -920,11 +921,11 @@ class DeviceDomain extends Domain { ...@@ -920,11 +921,11 @@ class DeviceDomain extends Domain {
hostPort = await device.portForwarder!.forward(devicePort, hostPort: hostPort); hostPort = await device.portForwarder!.forward(devicePort, hostPort: hostPort);
return <String, dynamic>{'hostPort': hostPort}; return <String, Object?>{'hostPort': hostPort};
} }
/// Removes a forwarded port. /// Removes a forwarded port.
Future<void> unforward(Map<String, dynamic> args) async { Future<void> unforward(Map<String, Object?> args) async {
final String? deviceId = _getStringArg(args, 'deviceId', required: true); final String? deviceId = _getStringArg(args, 'deviceId', required: true);
final int devicePort = _getIntArg(args, 'devicePort', required: true)!; final int devicePort = _getIntArg(args, 'devicePort', required: true)!;
final int hostPort = _getIntArg(args, 'hostPort', required: true)!; final int hostPort = _getIntArg(args, 'hostPort', required: true)!;
...@@ -938,7 +939,7 @@ class DeviceDomain extends Domain { ...@@ -938,7 +939,7 @@ class DeviceDomain extends Domain {
} }
/// Returns whether a device supports runtime mode. /// Returns whether a device supports runtime mode.
Future<bool> supportsRuntimeMode(Map<String, dynamic> args) async { Future<bool> supportsRuntimeMode(Map<String, Object?> args) async {
final String? deviceId = _getStringArg(args, 'deviceId', required: true); final String? deviceId = _getStringArg(args, 'deviceId', required: true);
final Device? device = await daemon.deviceDomain._getDevice(deviceId); final Device? device = await daemon.deviceDomain._getDevice(deviceId);
if (device == null) { if (device == null) {
...@@ -949,7 +950,7 @@ class DeviceDomain extends Domain { ...@@ -949,7 +950,7 @@ class DeviceDomain extends Domain {
} }
/// Creates an application package from a file in the temp directory. /// Creates an application package from a file in the temp directory.
Future<String> uploadApplicationPackage(Map<String, dynamic> args) async { Future<String> uploadApplicationPackage(Map<String, Object?> args) async {
final TargetPlatform targetPlatform = getTargetPlatformForName(_getStringArg(args, 'targetPlatform', required: true)!); final TargetPlatform targetPlatform = getTargetPlatformForName(_getStringArg(args, 'targetPlatform', required: true)!);
final File applicationBinary = daemon.proxyDomain.tempDirectory.childFile(_getStringArg(args, 'applicationBinary', required: true)!); final File applicationBinary = daemon.proxyDomain.tempDirectory.childFile(_getStringArg(args, 'applicationBinary', required: true)!);
final ApplicationPackage? applicationPackage = await ApplicationPackageFactory.instance!.getPackageForPlatform( final ApplicationPackage? applicationPackage = await ApplicationPackageFactory.instance!.getPackageForPlatform(
...@@ -962,7 +963,7 @@ class DeviceDomain extends Domain { ...@@ -962,7 +963,7 @@ class DeviceDomain extends Domain {
} }
/// Starts the log reader on the device. /// Starts the log reader on the device.
Future<String> startLogReader(Map<String, dynamic> args) async { Future<String> startLogReader(Map<String, Object?> args) async {
final String? deviceId = _getStringArg(args, 'deviceId', required: true); final String? deviceId = _getStringArg(args, 'deviceId', required: true);
final Device? device = await daemon.deviceDomain._getDevice(deviceId); final Device? device = await daemon.deviceDomain._getDevice(deviceId);
if (device == null) { if (device == null) {
...@@ -981,13 +982,13 @@ class DeviceDomain extends Domain { ...@@ -981,13 +982,13 @@ class DeviceDomain extends Domain {
} }
/// Stops a log reader that was previously started. /// Stops a log reader that was previously started.
Future<void> stopLogReader(Map<String, dynamic> args) async { Future<void> stopLogReader(Map<String, Object?> args) async {
final String? id = _getStringArg(args, 'id', required: true); final String? id = _getStringArg(args, 'id', required: true);
_logReaders.remove(id)?.dispose(); _logReaders.remove(id)?.dispose();
} }
/// Starts an app on a device. /// Starts an app on a device.
Future<Map<String, dynamic>> startApp(Map<String, dynamic> args) async { Future<Map<String, Object?>> startApp(Map<String, Object?> args) async {
final String? deviceId = _getStringArg(args, 'deviceId', required: true); final String? deviceId = _getStringArg(args, 'deviceId', required: true);
final Device? device = await daemon.deviceDomain._getDevice(deviceId); final Device? device = await daemon.deviceDomain._getDevice(deviceId);
if (device == null) { if (device == null) {
...@@ -1010,14 +1011,14 @@ class DeviceDomain extends Domain { ...@@ -1010,14 +1011,14 @@ class DeviceDomain extends Domain {
ipv6: _getBoolArg(args, 'ipv6') ?? false, ipv6: _getBoolArg(args, 'ipv6') ?? false,
userIdentifier: _getStringArg(args, 'userIdentifier'), userIdentifier: _getStringArg(args, 'userIdentifier'),
); );
return <String, dynamic>{ return <String, Object?>{
'started': result.started, 'started': result.started,
'observatoryUri': result.observatoryUri?.toString(), 'observatoryUri': result.observatoryUri?.toString(),
}; };
} }
/// Stops an app. /// Stops an app.
Future<bool> stopApp(Map<String, dynamic> args) async { Future<bool> stopApp(Map<String, Object?> args) async {
final String? deviceId = _getStringArg(args, 'deviceId', required: true); final String? deviceId = _getStringArg(args, 'deviceId', required: true);
final Device? device = await daemon.deviceDomain._getDevice(deviceId); final Device? device = await daemon.deviceDomain._getDevice(deviceId);
if (device == null) { if (device == null) {
...@@ -1032,7 +1033,7 @@ class DeviceDomain extends Domain { ...@@ -1032,7 +1033,7 @@ class DeviceDomain extends Domain {
} }
/// Takes a screenshot. /// Takes a screenshot.
Future<String?> takeScreenshot(Map<String, dynamic> args) async { Future<String?> takeScreenshot(Map<String, Object?> args) async {
final String? deviceId = _getStringArg(args, 'deviceId', required: true); final String? deviceId = _getStringArg(args, 'deviceId', required: true);
final Device? device = await daemon.deviceDomain._getDevice(deviceId); final Device? device = await daemon.deviceDomain._getDevice(deviceId);
if (device == null) { if (device == null) {
...@@ -1082,10 +1083,10 @@ class DevToolsDomain extends Domain { ...@@ -1082,10 +1083,10 @@ class DevToolsDomain extends Domain {
DevtoolsLauncher? _devtoolsLauncher; DevtoolsLauncher? _devtoolsLauncher;
Future<Map<String, dynamic>> serve([ Map<String, dynamic>? args ]) async { Future<Map<String, Object?>> serve([ Map<String, Object?>? args ]) async {
_devtoolsLauncher ??= DevtoolsLauncher.instance; _devtoolsLauncher ??= DevtoolsLauncher.instance;
final DevToolsServerAddress? server = await _devtoolsLauncher?.serve(); final DevToolsServerAddress? server = await _devtoolsLauncher?.serve();
return<String, dynamic>{ return<String, Object?>{
'host': server?.host, 'host': server?.host,
'port': server?.port, 'port': server?.port,
}; };
...@@ -1097,8 +1098,8 @@ class DevToolsDomain extends Domain { ...@@ -1097,8 +1098,8 @@ class DevToolsDomain extends Domain {
} }
} }
Future<Map<String, dynamic>> _deviceToMap(Device device) async { Future<Map<String, Object?>> _deviceToMap(Device device) async {
return <String, dynamic>{ return <String, Object?>{
'id': device.id, 'id': device.id,
'name': device.name, 'name': device.name,
'platform': getNameForTargetPlatform(await device.targetPlatform), 'platform': getNameForTargetPlatform(await device.targetPlatform),
...@@ -1120,8 +1121,8 @@ Future<Map<String, dynamic>> _deviceToMap(Device device) async { ...@@ -1120,8 +1121,8 @@ Future<Map<String, dynamic>> _deviceToMap(Device device) async {
}; };
} }
Map<String, dynamic> _emulatorToMap(Emulator emulator) { Map<String, Object?> _emulatorToMap(Emulator emulator) {
return <String, dynamic>{ return <String, Object?>{
'id': emulator.id, 'id': emulator.id,
'name': emulator.name, 'name': emulator.name,
'category': emulator.category.toString(), 'category': emulator.category.toString(),
...@@ -1129,15 +1130,15 @@ Map<String, dynamic> _emulatorToMap(Emulator emulator) { ...@@ -1129,15 +1130,15 @@ Map<String, dynamic> _emulatorToMap(Emulator emulator) {
}; };
} }
Map<String, dynamic> _operationResultToMap(OperationResult result) { Map<String, Object?> _operationResultToMap(OperationResult result) {
return <String, dynamic>{ return <String, Object?>{
'code': result.code, 'code': result.code,
'message': result.message, 'message': result.message,
}; };
} }
Object? _toJsonable(dynamic obj) { Object? _toJsonable(Object? obj) {
if (obj is String || obj is int || obj is bool || obj is Map<dynamic, dynamic> || obj is List<dynamic> || obj == null) { if (obj is String || obj is int || obj is bool || obj is Map<Object?, Object?> || obj is List<Object?> || obj == null) {
return obj; return obj;
} }
if (obj is OperationResult) { if (obj is OperationResult) {
...@@ -1250,7 +1251,7 @@ class NotifyingLogger extends DelegatingLogger { ...@@ -1250,7 +1251,7 @@ class NotifyingLogger extends DelegatingLogger {
} }
@override @override
void sendEvent(String name, [Map<String, dynamic>? args]) { } void sendEvent(String name, [Map<String, Object?>? args]) { }
@override @override
bool get supportsColor => throw UnimplementedError(); bool get supportsColor => throw UnimplementedError();
...@@ -1305,12 +1306,12 @@ class EmulatorDomain extends Domain { ...@@ -1305,12 +1306,12 @@ class EmulatorDomain extends Domain {
androidWorkflow: androidWorkflow!, androidWorkflow: androidWorkflow!,
); );
Future<List<Map<String, dynamic>>> getEmulators([ Map<String, dynamic>? args ]) async { Future<List<Map<String, Object?>>> getEmulators([ Map<String, Object?>? args ]) async {
final List<Emulator> list = await emulators.getAllAvailableEmulators(); final List<Emulator> list = await emulators.getAllAvailableEmulators();
return list.map<Map<String, dynamic>>(_emulatorToMap).toList(); return list.map<Map<String, Object?>>(_emulatorToMap).toList();
} }
Future<void> launch(Map<String, dynamic> args) async { Future<void> launch(Map<String, Object?> args) async {
final String emulatorId = _getStringArg(args, 'emulatorId', required: true)!; final String emulatorId = _getStringArg(args, 'emulatorId', required: true)!;
final bool coldBoot = _getBoolArg(args, 'coldBoot') ?? false; final bool coldBoot = _getBoolArg(args, 'coldBoot') ?? false;
final List<Emulator> matches = final List<Emulator> matches =
...@@ -1324,10 +1325,10 @@ class EmulatorDomain extends Domain { ...@@ -1324,10 +1325,10 @@ class EmulatorDomain extends Domain {
} }
} }
Future<Map<String, dynamic>> create(Map<String, dynamic> args) async { Future<Map<String, Object?>> create(Map<String, Object?> args) async {
final String? name = _getStringArg(args, 'name'); final String? name = _getStringArg(args, 'name');
final CreateEmulatorResult res = await emulators.createEmulator(name: name); final CreateEmulatorResult res = await emulators.createEmulator(name: name);
return <String, dynamic>{ return <String, Object?>{
'success': res.success, 'success': res.success,
'emulatorName': res.emulatorName, 'emulatorName': res.emulatorName,
'error': res.error, 'error': res.error,
...@@ -1349,7 +1350,7 @@ class ProxyDomain extends Domain { ...@@ -1349,7 +1350,7 @@ class ProxyDomain extends Domain {
int _id = 0; int _id = 0;
/// Writes to a file in a local temporary directory. /// Writes to a file in a local temporary directory.
Future<void> writeTempFile(Map<String, dynamic> args, Stream<List<int>>? binary) async { Future<void> writeTempFile(Map<String, Object?> args, Stream<List<int>>? binary) async {
final String path = _getStringArg(args, 'path', required: true)!; final String path = _getStringArg(args, 'path', required: true)!;
final File file = tempDirectory.childFile(path); final File file = tempDirectory.childFile(path);
await file.parent.create(recursive: true); await file.parent.create(recursive: true);
...@@ -1357,7 +1358,7 @@ class ProxyDomain extends Domain { ...@@ -1357,7 +1358,7 @@ class ProxyDomain extends Domain {
} }
/// Calculate rolling hashes for a file in the local temporary directory. /// Calculate rolling hashes for a file in the local temporary directory.
Future<Map<String, dynamic>?> calculateFileHashes(Map<String, dynamic> args) async { Future<Map<String, Object?>?> calculateFileHashes(Map<String, Object?> args) async {
final String path = _getStringArg(args, 'path', required: true)!; final String path = _getStringArg(args, 'path', required: true)!;
final File file = tempDirectory.childFile(path); final File file = tempDirectory.childFile(path);
if (!await file.exists()) { if (!await file.exists()) {
...@@ -1367,20 +1368,20 @@ class ProxyDomain extends Domain { ...@@ -1367,20 +1368,20 @@ class ProxyDomain extends Domain {
return result.toJson(); return result.toJson();
} }
Future<bool?> updateFile(Map<String, dynamic> args, Stream<List<int>>? binary) async { Future<bool?> updateFile(Map<String, Object?> args, Stream<List<int>>? binary) async {
final String path = _getStringArg(args, 'path', required: true)!; final String path = _getStringArg(args, 'path', required: true)!;
final File file = tempDirectory.childFile(path); final File file = tempDirectory.childFile(path);
if (!await file.exists()) { if (!await file.exists()) {
return null; return null;
} }
final List<Map<String, dynamic>> deltaJson = (args['delta'] as List<dynamic>).cast<Map<String, dynamic>>(); final List<Map<String, Object?>> deltaJson = (args['delta']! as List<Object?>).cast<Map<String, Object?>>();
final List<FileDeltaBlock> delta = FileDeltaBlock.fromJsonList(deltaJson); final List<FileDeltaBlock> delta = FileDeltaBlock.fromJsonList(deltaJson);
final bool result = await FileTransfer().rebuildFile(file, delta, binary!); final bool result = await FileTransfer().rebuildFile(file, delta, binary!);
return result; return result;
} }
/// Opens a connection to a local port, and returns the connection id. /// Opens a connection to a local port, and returns the connection id.
Future<String> connect(Map<String, dynamic> args) async { Future<String> connect(Map<String, Object?> args) async {
final int targetPort = _getIntArg(args, 'port', required: true)!; final int targetPort = _getIntArg(args, 'port', required: true)!;
final String id = 'portForwarder_${targetPort}_${_id++}'; final String id = 'portForwarder_${targetPort}_${_id++}';
...@@ -1406,22 +1407,22 @@ class ProxyDomain extends Domain { ...@@ -1406,22 +1407,22 @@ class ProxyDomain extends Domain {
_forwardedConnections[id] = socket; _forwardedConnections[id] = socket;
socket.listen((List<int> data) { socket.listen((List<int> data) {
sendEvent('proxy.data.$id', null, data); sendEvent('proxy.data.$id', null, data);
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (Object error, StackTrace stackTrace) {
// Socket error, probably disconnected. // Socket error, probably disconnected.
globals.logger.printTrace('Socket error: $error, $stackTrace'); globals.logger.printTrace('Socket error: $error, $stackTrace');
}); });
unawaited(socket.done.catchError((dynamic error, StackTrace stackTrace) { unawaited(socket.done.catchError((Object error, StackTrace stackTrace) {
// Socket error, probably disconnected. // Socket error, probably disconnected.
globals.logger.printTrace('Socket error: $error, $stackTrace'); globals.logger.printTrace('Socket error: $error, $stackTrace');
}).then((dynamic _) { }).then((Object? _) {
sendEvent('proxy.disconnected.$id'); sendEvent('proxy.disconnected.$id');
})); }));
return id; return id;
} }
/// Disconnects from a previously established connection. /// Disconnects from a previously established connection.
Future<bool> disconnect(Map<String, dynamic> args) async { Future<bool> disconnect(Map<String, Object?> args) async {
final String? id = _getStringArg(args, 'id', required: true); final String? id = _getStringArg(args, 'id', required: true);
if (_forwardedConnections.containsKey(id)) { if (_forwardedConnections.containsKey(id)) {
await _forwardedConnections.remove(id)?.close(); await _forwardedConnections.remove(id)?.close();
...@@ -1431,7 +1432,7 @@ class ProxyDomain extends Domain { ...@@ -1431,7 +1432,7 @@ class ProxyDomain extends Domain {
} }
/// Writes to a previously established connection. /// Writes to a previously established connection.
Future<bool> write(Map<String, dynamic> args, Stream<List<int>>? binary) async { Future<bool> write(Map<String, Object?> args, Stream<List<int>>? binary) async {
final String? id = _getStringArg(args, 'id', required: true); final String? id = _getStringArg(args, 'id', required: true);
if (_forwardedConnections.containsKey(id)) { if (_forwardedConnections.containsKey(id)) {
final StreamSubscription<List<int>> subscription = binary!.listen(_forwardedConnections[id!]!.add); final StreamSubscription<List<int>> subscription = binary!.listen(_forwardedConnections[id!]!.add);
...@@ -1519,7 +1520,7 @@ class AppRunLogger extends DelegatingLogger { ...@@ -1519,7 +1520,7 @@ class AppRunLogger extends DelegatingLogger {
printStatus(message); printStatus(message);
} }
} else { } else {
final Map<String, dynamic> event = <String, dynamic>{ final Map<String, Object?> event = <String, Object?>{
'id': eventId, 'id': eventId,
'progressId': eventType, 'progressId': eventType,
if (message != null) 'message': message, if (message != null) 'message': message,
...@@ -1531,7 +1532,7 @@ class AppRunLogger extends DelegatingLogger { ...@@ -1531,7 +1532,7 @@ class AppRunLogger extends DelegatingLogger {
} }
@override @override
void sendEvent(String name, [Map<String, dynamic>? args, List<int>? binary]) { void sendEvent(String name, [Map<String, Object?>? args, List<int>? binary]) {
if (domain == null) { if (domain == null) {
printStatus('event sent after app closed: $name'); printStatus('event sent after app closed: $name');
} else { } else {
......
...@@ -81,14 +81,14 @@ const String kExitMessage = 'Failed to establish connection with the application ...@@ -81,14 +81,14 @@ const String kExitMessage = 'Failed to establish connection with the application
class ResidentWebRunner extends ResidentRunner { class ResidentWebRunner extends ResidentRunner {
ResidentWebRunner( ResidentWebRunner(
FlutterDevice? device, { FlutterDevice device, {
String? target, String? target,
bool stayResident = true, bool stayResident = true,
bool machine = false, bool machine = false,
required this.flutterProject, required this.flutterProject,
required bool? ipv6, required bool? ipv6,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
required FileSystem? fileSystem, required FileSystem fileSystem,
required Logger? logger, required Logger? logger,
required SystemClock systemClock, required SystemClock systemClock,
required Usage usage, required Usage usage,
...@@ -100,8 +100,8 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -100,8 +100,8 @@ class ResidentWebRunner extends ResidentRunner {
_usage = usage, _usage = usage,
_urlTunneller = urlTunneller, _urlTunneller = urlTunneller,
super( super(
<FlutterDevice?>[device], <FlutterDevice>[device],
target: target ?? fileSystem!.path.join('lib', 'main.dart'), target: target ?? fileSystem.path.join('lib', 'main.dart'),
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
ipv6: ipv6, ipv6: ipv6,
stayResident: stayResident, stayResident: stayResident,
...@@ -109,7 +109,7 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -109,7 +109,7 @@ class ResidentWebRunner extends ResidentRunner {
devtoolsHandler: devtoolsHandler, devtoolsHandler: devtoolsHandler,
); );
final FileSystem? _fileSystem; final FileSystem _fileSystem;
final Logger? _logger; final Logger? _logger;
final SystemClock _systemClock; final SystemClock _systemClock;
final Usage _usage; final Usage _usage;
...@@ -119,7 +119,7 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -119,7 +119,7 @@ class ResidentWebRunner extends ResidentRunner {
Logger? get logger => _logger; Logger? get logger => _logger;
@override @override
FileSystem? get fileSystem => _fileSystem; FileSystem get fileSystem => _fileSystem;
FlutterDevice? get device => flutterDevices.first; FlutterDevice? get device => flutterDevices.first;
final FlutterProject flutterProject; final FlutterProject flutterProject;
...@@ -245,7 +245,7 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -245,7 +245,7 @@ class ResidentWebRunner extends ResidentRunner {
} }
final String modeName = debuggingOptions.buildInfo.friendlyModeName; final String modeName = debuggingOptions.buildInfo.friendlyModeName;
_logger!.printStatus( _logger!.printStatus(
'Launching ${getDisplayPath(target, _fileSystem!)} ' 'Launching ${getDisplayPath(target, _fileSystem)} '
'on ${device!.device!.name} in $modeName mode...', 'on ${device!.device!.name} in $modeName mode...',
); );
if (device!.device is ChromiumDevice) { if (device!.device is ChromiumDevice) {
...@@ -271,7 +271,7 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -271,7 +271,7 @@ class ResidentWebRunner extends ResidentRunner {
buildInfo: debuggingOptions.buildInfo, buildInfo: debuggingOptions.buildInfo,
enableDwds: _enableDwds, enableDwds: _enableDwds,
enableDds: debuggingOptions.enableDds, enableDds: debuggingOptions.enableDds,
entrypoint: _fileSystem!.file(target).uri, entrypoint: _fileSystem.file(target).uri,
expressionCompiler: expressionCompiler, expressionCompiler: expressionCompiler,
chromiumLauncher: _chromiumLauncher, chromiumLauncher: _chromiumLauncher,
nullAssertions: debuggingOptions.nullAssertions, nullAssertions: debuggingOptions.nullAssertions,
...@@ -425,7 +425,7 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -425,7 +425,7 @@ class ResidentWebRunner extends ResidentRunner {
Future<Uri> _generateEntrypoint(Uri mainUri, PackageConfig? packageConfig) async { Future<Uri> _generateEntrypoint(Uri mainUri, PackageConfig? packageConfig) async {
File? result = _generatedEntrypointDirectory?.childFile('web_entrypoint.dart'); File? result = _generatedEntrypointDirectory?.childFile('web_entrypoint.dart');
if (_generatedEntrypointDirectory == null) { if (_generatedEntrypointDirectory == null) {
_generatedEntrypointDirectory ??= _fileSystem!.systemTempDirectory.createTempSync('flutter_tools.') _generatedEntrypointDirectory ??= _fileSystem.systemTempDirectory.createTempSync('flutter_tools.')
..createSync(); ..createSync();
result = _generatedEntrypointDirectory!.childFile('web_entrypoint.dart'); result = _generatedEntrypointDirectory!.childFile('web_entrypoint.dart');
...@@ -438,16 +438,17 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -438,16 +438,17 @@ class ResidentWebRunner extends ResidentRunner {
Uri? importedEntrypoint = packageConfig!.toPackageUri(mainUri); Uri? importedEntrypoint = packageConfig!.toPackageUri(mainUri);
// Special handling for entrypoints that are not under lib, such as test scripts. // Special handling for entrypoints that are not under lib, such as test scripts.
if (importedEntrypoint == null) { if (importedEntrypoint == null) {
final String parent = _fileSystem!.file(mainUri).parent.path; final String parent = _fileSystem.file(mainUri).parent.path;
flutterDevices.first!.generator!.addFileSystemRoot(parent); flutterDevices.first.generator!
flutterDevices.first!.generator!.addFileSystemRoot(_fileSystem!.directory('test').absolute.path); ..addFileSystemRoot(parent)
..addFileSystemRoot(_fileSystem.directory('test').absolute.path);
importedEntrypoint = Uri( importedEntrypoint = Uri(
scheme: 'org-dartlang-app', scheme: 'org-dartlang-app',
path: '/${mainUri.pathSegments.last}', path: '/${mainUri.pathSegments.last}',
); );
} }
final LanguageVersion languageVersion = determineLanguageVersion( final LanguageVersion languageVersion = determineLanguageVersion(
_fileSystem!.file(mainUri), _fileSystem.file(mainUri),
packageConfig[flutterProject.manifest.appName], packageConfig[flutterProject.manifest.appName],
Cache.flutterRoot!, Cache.flutterRoot!,
); );
...@@ -487,7 +488,7 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -487,7 +488,7 @@ class ResidentWebRunner extends ResidentRunner {
); );
final UpdateFSReport report = await device!.devFS!.update( final UpdateFSReport report = await device!.devFS!.update(
mainUri: await _generateEntrypoint( mainUri: await _generateEntrypoint(
_fileSystem!.file(mainPath).absolute.uri, _fileSystem.file(mainPath).absolute.uri,
invalidationResult.packageConfig, invalidationResult.packageConfig,
), ),
target: target, target: target,
...@@ -603,7 +604,7 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -603,7 +604,7 @@ class ResidentWebRunner extends ResidentRunner {
} }
if (websocketUri != null) { if (websocketUri != null) {
if (debuggingOptions.vmserviceOutFile != null) { if (debuggingOptions.vmserviceOutFile != null) {
_fileSystem!.file(debuggingOptions.vmserviceOutFile) _fileSystem.file(debuggingOptions.vmserviceOutFile)
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync(websocketUri.toString()); ..writeAsStringSync(websocketUri.toString());
} }
......
...@@ -240,7 +240,7 @@ class FlutterDevice { ...@@ -240,7 +240,7 @@ class FlutterDevice {
bool cacheStartupProfile = false, bool cacheStartupProfile = false,
bool enableDds = true, bool enableDds = true,
required bool allowExistingDdsInstance, required bool allowExistingDdsInstance,
bool? ipv6 = false, bool ipv6 = false,
}) { }) {
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
late StreamSubscription<void> subscription; late StreamSubscription<void> subscription;
...@@ -927,14 +927,14 @@ abstract class ResidentHandlers { ...@@ -927,14 +927,14 @@ abstract class ResidentHandlers {
if (!supportsWriteSkSL) { if (!supportsWriteSkSL) {
throw Exception('writeSkSL is not supported by this runner.'); throw Exception('writeSkSL is not supported by this runner.');
} }
final List<FlutterView> views = await flutterDevices final FlutterDevice flutterDevice = flutterDevices.first!;
.first! final FlutterVmService vmService = flutterDevice.vmService!;
.vmService!.getFlutterViews(); final List<FlutterView> views = await vmService.getFlutterViews();
final Map<String, Object> data = await (flutterDevices.first!.vmService!.getSkSLs( final Map<String, Object?>? data = await vmService.getSkSLs(
viewId: views.first.id, viewId: views.first.id,
) as FutureOr<Map<String, Object>>); );
final Device device = flutterDevices.first!.device!; final Device device = flutterDevice.device!;
return sharedSkSlWriter(device, data); return sharedSkSlWriter(device, data!);
} }
/// Take a screenshot on the provided [device]. /// Take a screenshot on the provided [device].
...@@ -1091,10 +1091,10 @@ abstract class ResidentRunner extends ResidentHandlers { ...@@ -1091,10 +1091,10 @@ abstract class ResidentRunner extends ResidentHandlers {
Logger? get logger => globals.logger; Logger? get logger => globals.logger;
@override @override
FileSystem? get fileSystem => globals.fs; FileSystem get fileSystem => globals.fs;
@override @override
final List<FlutterDevice?> flutterDevices; final List<FlutterDevice> flutterDevices;
final String target; final String target;
final DebuggingOptions debuggingOptions; final DebuggingOptions debuggingOptions;
...@@ -1171,7 +1171,7 @@ abstract class ResidentRunner extends ResidentHandlers { ...@@ -1171,7 +1171,7 @@ abstract class ResidentRunner extends ResidentHandlers {
// //
// Would be null if there is no device connected or // Would be null if there is no device connected or
// there is no devFS associated with the first device. // there is no devFS associated with the first device.
Uri? get uri => flutterDevices.first?.devFS?.baseUri; Uri? get uri => flutterDevices.first.devFS?.baseUri;
/// Returns [true] if the resident runner exited after invoking [exit()]. /// Returns [true] if the resident runner exited after invoking [exit()].
bool get exited => _exited; bool get exited => _exited;
...@@ -1257,7 +1257,7 @@ abstract class ResidentRunner extends ResidentHandlers { ...@@ -1257,7 +1257,7 @@ abstract class ResidentRunner extends ResidentHandlers {
void writeVmServiceFile() { void writeVmServiceFile() {
if (debuggingOptions.vmserviceOutFile != null) { if (debuggingOptions.vmserviceOutFile != null) {
try { try {
final String address = flutterDevices.first!.vmService!.wsAddress.toString(); final String address = flutterDevices.first.vmService!.wsAddress.toString();
final File vmserviceOutFile = globals.fs.file(debuggingOptions.vmserviceOutFile); final File vmserviceOutFile = globals.fs.file(debuggingOptions.vmserviceOutFile);
vmserviceOutFile.createSync(recursive: true); vmserviceOutFile.createSync(recursive: true);
vmserviceOutFile.writeAsStringSync(address); vmserviceOutFile.writeAsStringSync(address);
...@@ -1359,7 +1359,7 @@ abstract class ResidentRunner extends ResidentHandlers { ...@@ -1359,7 +1359,7 @@ abstract class ResidentRunner extends ResidentHandlers {
hostVmServicePort: debuggingOptions.hostVmServicePort, hostVmServicePort: debuggingOptions.hostVmServicePort,
getSkSLMethod: getSkSLMethod, getSkSLMethod: getSkSLMethod,
printStructuredErrorLogMethod: printStructuredErrorLog, printStructuredErrorLogMethod: printStructuredErrorLog,
ipv6: ipv6, ipv6: ipv6 ?? false,
disableServiceAuthCodes: debuggingOptions.disableServiceAuthCodes, disableServiceAuthCodes: debuggingOptions.disableServiceAuthCodes,
cacheStartupProfile: debuggingOptions.cacheStartupProfile, cacheStartupProfile: debuggingOptions.cacheStartupProfile,
); );
......
...@@ -88,11 +88,11 @@ class ColdRunner extends ResidentRunner { ...@@ -88,11 +88,11 @@ class ColdRunner extends ResidentRunner {
)); ));
} }
if (flutterDevices.first!.observatoryUris != null) { if (flutterDevices.first.observatoryUris != null) {
// For now, only support one debugger connection. // For now, only support one debugger connection.
connectionInfoCompleter?.complete(DebugConnectionInfo( connectionInfoCompleter?.complete(DebugConnectionInfo(
httpUri: flutterDevices.first!.vmService!.httpAddress, httpUri: flutterDevices.first.vmService!.httpAddress,
wsUri: flutterDevices.first!.vmService!.wsAddress, wsUri: flutterDevices.first.vmService!.wsAddress,
)); ));
} }
...@@ -108,7 +108,7 @@ class ColdRunner extends ResidentRunner { ...@@ -108,7 +108,7 @@ class ColdRunner extends ResidentRunner {
if (traceStartup) { if (traceStartup) {
// Only trace startup for the first device. // Only trace startup for the first device.
final FlutterDevice device = flutterDevices.first!; final FlutterDevice device = flutterDevices.first;
if (device.vmService != null) { if (device.vmService != null) {
globals.printStatus('Tracing startup on ${device.device!.name}.'); globals.printStatus('Tracing startup on ${device.device!.name}.');
final String outputPath = globals.platform.environment[kFlutterTestOutputsDirEnvName] ?? getBuildDirectory(); final String outputPath = globals.platform.environment[kFlutterTestOutputsDirEnvName] ?? getBuildDirectory();
......
...@@ -141,7 +141,7 @@ class HotRunner extends ResidentRunner { ...@@ -141,7 +141,7 @@ class HotRunner extends ResidentRunner {
} }
if (flutterDevices.length == 1) { if (flutterDevices.length == 1) {
final Device device = flutterDevices.first!.device!; final Device device = flutterDevices.first.device!;
_targetPlatform = getNameForTargetPlatform(await device.targetPlatform); _targetPlatform = getNameForTargetPlatform(await device.targetPlatform);
_sdkName = await device.sdkNameAndVersion; _sdkName = await device.sdkNameAndVersion;
_emulator = await device.isLocalEmulator; _emulator = await device.isLocalEmulator;
...@@ -257,8 +257,8 @@ class HotRunner extends ResidentRunner { ...@@ -257,8 +257,8 @@ class HotRunner extends ResidentRunner {
// Only handle one debugger connection. // Only handle one debugger connection.
connectionInfoCompleter.complete( connectionInfoCompleter.complete(
DebugConnectionInfo( DebugConnectionInfo(
httpUri: flutterDevices.first!.vmService!.httpAddress, httpUri: flutterDevices.first.vmService!.httpAddress,
wsUri: flutterDevices.first!.vmService!.wsAddress, wsUri: flutterDevices.first.vmService!.wsAddress,
baseUri: baseUris.first.toString(), baseUri: baseUris.first.toString(),
), ),
); );
...@@ -454,12 +454,13 @@ class HotRunner extends ResidentRunner { ...@@ -454,12 +454,13 @@ class HotRunner extends ResidentRunner {
} }
final Stopwatch findInvalidationTimer = _stopwatchFactory.createStopwatch('updateDevFS')..start(); final Stopwatch findInvalidationTimer = _stopwatchFactory.createStopwatch('updateDevFS')..start();
final DevFS devFS = flutterDevices[0].devFS!;
final InvalidationResult invalidationResult = await projectFileInvalidator.findInvalidated( final InvalidationResult invalidationResult = await projectFileInvalidator.findInvalidated(
lastCompiled: flutterDevices[0]!.devFS!.lastCompiled, lastCompiled: devFS.lastCompiled,
urisToMonitor: flutterDevices[0]!.devFS!.sources, urisToMonitor: devFS.sources,
packagesPath: packagesFilePath, packagesPath: packagesFilePath,
asyncScanning: hotRunnerConfig!.asyncScanning, asyncScanning: hotRunnerConfig!.asyncScanning,
packageConfig: flutterDevices[0]!.devFS!.lastPackageConfig packageConfig: devFS.lastPackageConfig
?? debuggingOptions.buildInfo.packageConfig, ?? debuggingOptions.buildInfo.packageConfig,
); );
findInvalidationTimer.stop(); findInvalidationTimer.stop();
...@@ -474,7 +475,7 @@ class HotRunner extends ResidentRunner { ...@@ -474,7 +475,7 @@ class HotRunner extends ResidentRunner {
} }
final UpdateFSReport results = UpdateFSReport( final UpdateFSReport results = UpdateFSReport(
success: true, success: true,
scannedSourcesCount: flutterDevices[0]!.devFS!.sources.length, scannedSourcesCount: devFS.sources.length,
findInvalidatedDuration: findInvalidationTimer.elapsed, findInvalidatedDuration: findInvalidationTimer.elapsed,
); );
for (final FlutterDevice? device in flutterDevices) { for (final FlutterDevice? device in flutterDevices) {
...@@ -497,21 +498,27 @@ class HotRunner extends ResidentRunner { ...@@ -497,21 +498,27 @@ class HotRunner extends ResidentRunner {
} }
void _resetDirtyAssets() { void _resetDirtyAssets() {
for (final FlutterDevice? device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
device!.devFS!.assetPathsToEvict.clear(); final DevFS? devFS = device.devFS;
device.devFS!.shaderPathsToEvict.clear(); if (devFS == null) {
// This is sometimes null, however we don't know why and have not been
// able to reproduce, https://github.com/flutter/flutter/issues/108653
continue;
}
devFS.assetPathsToEvict.clear();
devFS.shaderPathsToEvict.clear();
} }
} }
Future<void> _cleanupDevFS() async { Future<void> _cleanupDevFS() async {
final List<Future<void>> futures = <Future<void>>[]; final List<Future<void>> futures = <Future<void>>[];
for (final FlutterDevice? device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
if (device!.devFS != null) { if (device.devFS != null) {
// Cleanup the devFS, but don't wait indefinitely. // Cleanup the devFS, but don't wait indefinitely.
// We ignore any errors, because it's not clear what we would do anyway. // We ignore any errors, because it's not clear what we would do anyway.
futures.add(device.devFS!.destroy() futures.add(device.devFS!.destroy()
.timeout(const Duration(milliseconds: 250)) .timeout(const Duration(milliseconds: 250))
.catchError((dynamic error) { .catchError((Object? error) {
globals.printTrace('Ignored error while cleaning up DevFS: $error'); globals.printTrace('Ignored error while cleaning up DevFS: $error');
})); }));
} }
...@@ -756,7 +763,7 @@ class HotRunner extends ResidentRunner { ...@@ -756,7 +763,7 @@ class HotRunner extends ResidentRunner {
String? restartEvent; String? restartEvent;
try { try {
final Stopwatch restartTimer = _stopwatchFactory.createStopwatch('fullRestartHelper')..start(); final Stopwatch restartTimer = _stopwatchFactory.createStopwatch('fullRestartHelper')..start();
if (!(await (hotRunnerConfig!.setupHotRestart() as FutureOr<bool>))) { if ((await hotRunnerConfig!.setupHotRestart()) != true) {
return OperationResult(1, 'setupHotRestart failed'); return OperationResult(1, 'setupHotRestart failed');
} }
result = await _restartFromSources(reason: reason); result = await _restartFromSources(reason: reason);
...@@ -885,7 +892,7 @@ class HotRunner extends ResidentRunner { ...@@ -885,7 +892,7 @@ class HotRunner extends ResidentRunner {
} }
final Stopwatch reloadTimer = _stopwatchFactory.createStopwatch('reloadSources:reload')..start(); final Stopwatch reloadTimer = _stopwatchFactory.createStopwatch('reloadSources:reload')..start();
if (!(await (hotRunnerConfig!.setupHotReload() as FutureOr<bool>))) { if ((await hotRunnerConfig!.setupHotReload()) != true) {
return OperationResult(1, 'setupHotReload failed'); return OperationResult(1, 'setupHotReload failed');
} }
final Stopwatch devFSTimer = Stopwatch()..start(); final Stopwatch devFSTimer = Stopwatch()..start();
......
...@@ -13,7 +13,7 @@ import 'convert.dart'; ...@@ -13,7 +13,7 @@ import 'convert.dart';
import 'device.dart'; import 'device.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
Future<String?> sharedSkSlWriter(Device device, Map<String, Object> data, { Future<String?> sharedSkSlWriter(Device device, Map<String, Object?> data, {
File? outputFile, File? outputFile,
Logger? logger, Logger? logger,
}) async { }) async {
......
...@@ -493,7 +493,7 @@ class FlutterVmService { ...@@ -493,7 +493,7 @@ class FlutterVmService {
/// ///
/// This method will only return data if `--cache-sksl` was provided as a /// This method will only return data if `--cache-sksl` was provided as a
/// flutter run argument, and only then on physical devices. /// flutter run argument, and only then on physical devices.
Future<Map<String, Object>?> getSkSLs({ Future<Map<String, Object?>?> getSkSLs({
required String viewId, required String viewId,
}) async { }) async {
final vm_service.Response? response = await callMethodWrapper( final vm_service.Response? response = await callMethodWrapper(
...@@ -505,7 +505,7 @@ class FlutterVmService { ...@@ -505,7 +505,7 @@ class FlutterVmService {
if (response == null) { if (response == null) {
return null; return null;
} }
return response.json?['SkSLs'] as Map<String, Object>?; return response.json?['SkSLs'] as Map<String, Object?>?;
} }
/// Flush all tasks on the UI thread for an attached Flutter view. /// Flush all tasks on the UI thread for an attached Flutter view.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:dds/dds.dart' as dds; import 'package:dds/dds.dart' as dds;
...@@ -35,7 +33,6 @@ import 'package:flutter_tools/src/run_cold.dart'; ...@@ -35,7 +33,6 @@ import 'package:flutter_tools/src/run_cold.dart';
import 'package:flutter_tools/src/run_hot.dart'; import 'package:flutter_tools/src/run_hot.dart';
import 'package:flutter_tools/src/version.dart'; import 'package:flutter_tools/src/version.dart';
import 'package:flutter_tools/src/vmservice.dart'; import 'package:flutter_tools/src/vmservice.dart';
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart' as vm_service; import 'package:vm_service/vm_service.dart' as vm_service;
...@@ -157,12 +154,12 @@ const FakeVmServiceRequest evictShader = FakeVmServiceRequest( ...@@ -157,12 +154,12 @@ const FakeVmServiceRequest evictShader = FakeVmServiceRequest(
final Uri testUri = Uri.parse('foo://bar'); final Uri testUri = Uri.parse('foo://bar');
void main() { void main() {
Testbed testbed; late Testbed testbed;
FakeFlutterDevice flutterDevice; late FakeFlutterDevice flutterDevice;
FakeDevFS devFS; late FakeDevFS devFS;
ResidentRunner residentRunner; late ResidentRunner residentRunner;
FakeDevice device; late FakeDevice device;
FakeVmServiceHost fakeVmServiceHost; FakeVmServiceHost? fakeVmServiceHost;
setUp(() { setUp(() {
testbed = Testbed(setup: () { testbed = Testbed(setup: () {
...@@ -197,7 +194,7 @@ void main() { ...@@ -197,7 +194,7 @@ void main() {
]); ]);
final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync(); final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync();
final Completer<void> futureAppStart = Completer<void>.sync(); final Completer<void> futureAppStart = Completer<void>.sync();
final Future<int> result = residentRunner.attach( final Future<int?> result = residentRunner.attach(
appStartedCompleter: futureAppStart, appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo, connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true, enableDevTools: true,
...@@ -208,7 +205,7 @@ void main() { ...@@ -208,7 +205,7 @@ void main() {
expect(futureConnectionInfo.isCompleted, true); expect(futureConnectionInfo.isCompleted, true);
expect((await connectionInfo).baseUri, 'foo://bar'); expect((await connectionInfo).baseUri, 'foo://bar');
expect(futureAppStart.isCompleted, true); expect(futureAppStart.isCompleted, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner suppresses errors for the initial compilation', () => testbed.run(() async { testUsingContext('ResidentRunner suppresses errors for the initial compilation', () => testbed.run(() async {
...@@ -233,7 +230,7 @@ void main() { ...@@ -233,7 +230,7 @@ void main() {
expect(await residentRunner.run(enableDevTools: true), 0); expect(await residentRunner.run(enableDevTools: true), 0);
expect(residentCompiler.didSuppressErrors, true); expect(residentCompiler.didSuppressErrors, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
// Regression test for https://github.com/flutter/flutter/issues/60613 // Regression test for https://github.com/flutter/flutter/issues/60613
...@@ -325,7 +322,7 @@ void main() { ...@@ -325,7 +322,7 @@ void main() {
expect(await residentRunner.run(enableDevTools: true), 0); expect(await residentRunner.run(enableDevTools: true), 0);
expect(residentCompiler.didSuppressErrors, false); expect(residentCompiler.didSuppressErrors, false);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner can attach to device successfully with --fast-start', () => testbed.run(() async { testUsingContext('ResidentRunner can attach to device successfully with --fast-start', () => testbed.run(() async {
...@@ -335,14 +332,14 @@ void main() { ...@@ -335,14 +332,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
jsonResponse: fakeUnpausedIsolate.toJson(), jsonResponse: fakeUnpausedIsolate.toJson(),
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{}).toJson(), jsonResponse: vm_service.VM.parse(<String, Object>{})!.toJson(),
), ),
listViews, listViews,
const FakeVmServiceRequest( const FakeVmServiceRequest(
...@@ -382,7 +379,7 @@ void main() { ...@@ -382,7 +379,7 @@ void main() {
); );
final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync(); final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync();
final Completer<void> futureAppStart = Completer<void>.sync(); final Completer<void> futureAppStart = Completer<void>.sync();
final Future<int> result = residentRunner.attach( final Future<int?> result = residentRunner.attach(
appStartedCompleter: futureAppStart, appStartedCompleter: futureAppStart,
connectionInfoCompleter: futureConnectionInfo, connectionInfoCompleter: futureConnectionInfo,
enableDevTools: true, enableDevTools: true,
...@@ -393,7 +390,7 @@ void main() { ...@@ -393,7 +390,7 @@ void main() {
expect(futureConnectionInfo.isCompleted, true); expect(futureConnectionInfo.isCompleted, true);
expect((await connectionInfo).baseUri, 'foo://bar'); expect((await connectionInfo).baseUri, 'foo://bar');
expect(futureAppStart.isCompleted, true); expect(futureAppStart.isCompleted, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner can handle an RPC exception from hot reload', () => testbed.run(() async { testUsingContext('ResidentRunner can handle an RPC exception from hot reload', () => testbed.run(() async {
...@@ -424,7 +421,7 @@ void main() { ...@@ -424,7 +421,7 @@ void main() {
fastReassemble: false, fastReassemble: false,
)), )),
)); ));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Usage: () => TestUsage(), Usage: () => TestUsage(),
})); }));
...@@ -447,7 +444,7 @@ void main() { ...@@ -447,7 +444,7 @@ void main() {
expect(result.fatal, false); expect(result.fatal, false);
expect(result.code, 1); expect(result.code, 1);
expect(result.message, contains('Device initialization has not completed.')); expect(result.message, contains('Device initialization has not completed.'));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner can handle an reload-barred exception from hot reload', () => testbed.run(() async { testUsingContext('ResidentRunner can handle an reload-barred exception from hot reload', () => testbed.run(() async {
...@@ -480,7 +477,7 @@ void main() { ...@@ -480,7 +477,7 @@ void main() {
fastReassemble: false, fastReassemble: false,
)), )),
)); ));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Usage: () => TestUsage(), Usage: () => TestUsage(),
})); }));
...@@ -527,7 +524,7 @@ void main() { ...@@ -527,7 +524,7 @@ void main() {
fastReassemble: false, fastReassemble: false,
)), )),
)); ));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Usage: () => TestUsage(), Usage: () => TestUsage(),
})); }));
...@@ -546,7 +543,7 @@ void main() { ...@@ -546,7 +543,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.reassemble', method: 'ext.flutter.reassemble',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
), ),
...@@ -573,7 +570,7 @@ void main() { ...@@ -573,7 +570,7 @@ void main() {
final OperationResult result = await residentRunner.restart(); final OperationResult result = await residentRunner.restart();
expect(result.code, 0); expect(result.code, 0);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner reports error with missing entrypoint file', () => testbed.run(() async { testUsingContext('ResidentRunner reports error with missing entrypoint file', () => testbed.run(() async {
...@@ -587,7 +584,7 @@ void main() { ...@@ -587,7 +584,7 @@ void main() {
'isolates': <Object>[ 'isolates': <Object>[
fakeUnpausedIsolate.toJson(), fakeUnpausedIsolate.toJson(),
], ],
}).toJson(), })!.toJson(),
), ),
const FakeVmServiceRequest( const FakeVmServiceRequest(
method: 'reloadSources', method: 'reloadSources',
...@@ -613,7 +610,7 @@ void main() { ...@@ -613,7 +610,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.reassemble', method: 'ext.flutter.reassemble',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
), ),
...@@ -647,7 +644,7 @@ void main() { ...@@ -647,7 +644,7 @@ void main() {
'isolates': <Object>[ 'isolates': <Object>[
fakeUnpausedIsolate.toJson(), fakeUnpausedIsolate.toJson(),
], ],
}).toJson(), })!.toJson(),
), ),
const FakeVmServiceRequest( const FakeVmServiceRequest(
method: 'reloadSources', method: 'reloadSources',
...@@ -677,7 +674,7 @@ void main() { ...@@ -677,7 +674,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.reassemble', method: 'ext.flutter.reassemble',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
), ),
...@@ -711,7 +708,7 @@ void main() { ...@@ -711,7 +708,7 @@ void main() {
'isolates': <Object>[ 'isolates': <Object>[
fakeUnpausedIsolate.toJson(), fakeUnpausedIsolate.toJson(),
], ],
}).toJson(), })!.toJson(),
), ),
const FakeVmServiceRequest( const FakeVmServiceRequest(
method: 'reloadSources', method: 'reloadSources',
...@@ -737,7 +734,7 @@ void main() { ...@@ -737,7 +734,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.reassemble', method: 'ext.flutter.reassemble',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
), ),
...@@ -758,7 +755,7 @@ void main() { ...@@ -758,7 +755,7 @@ void main() {
final TestUsageEvent event = (globals.flutterUsage as TestUsage).events.first; final TestUsageEvent event = (globals.flutterUsage as TestUsage).events.first;
expect(event.category, 'hot'); expect(event.category, 'hot');
expect(event.parameter, 'reload'); expect(event.parameter, 'reload');
expect(event.parameters.hotEventTargetPlatform, getNameForTargetPlatform(TargetPlatform.android_arm)); expect(event.parameters?.hotEventTargetPlatform, getNameForTargetPlatform(TargetPlatform.android_arm));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Usage: () => TestUsage(), Usage: () => TestUsage(),
})); }));
...@@ -800,7 +797,7 @@ void main() { ...@@ -800,7 +797,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.fastReassemble', method: 'ext.flutter.fastReassemble',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'className': 'FOO', 'className': 'FOO',
}, },
...@@ -811,7 +808,7 @@ void main() { ...@@ -811,7 +808,7 @@ void main() {
BuildInfo.debug, BuildInfo.debug,
FakeResidentCompiler(), FakeResidentCompiler(),
devFS, devFS,
)..vmService = fakeVmServiceHost.vmService; )..vmService = fakeVmServiceHost!.vmService;
residentRunner = HotRunner( residentRunner = HotRunner(
<FlutterDevice>[ <FlutterDevice>[
flutterDevice, flutterDevice,
...@@ -844,7 +841,7 @@ void main() { ...@@ -844,7 +841,7 @@ void main() {
final TestUsageEvent event = (globals.flutterUsage as TestUsage).events.first; final TestUsageEvent event = (globals.flutterUsage as TestUsage).events.first;
expect(event.category, 'hot'); expect(event.category, 'hot');
expect(event.parameter, 'reload'); expect(event.parameter, 'reload');
expect(event.parameters.fastReassemble, true); expect(event.parameters?.fastReassemble, true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
Platform: () => FakePlatform(), Platform: () => FakePlatform(),
...@@ -891,7 +888,7 @@ void main() { ...@@ -891,7 +888,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.fastReassemble', method: 'ext.flutter.fastReassemble',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'className': 'FOO', 'className': 'FOO',
}, },
...@@ -902,7 +899,7 @@ void main() { ...@@ -902,7 +899,7 @@ void main() {
BuildInfo.debug, BuildInfo.debug,
FakeResidentCompiler(), FakeResidentCompiler(),
devFS, devFS,
)..vmService = fakeVmServiceHost.vmService; )..vmService = fakeVmServiceHost!.vmService;
residentRunner = HotRunner( residentRunner = HotRunner(
<FlutterDevice>[ <FlutterDevice>[
flutterDevice, flutterDevice,
...@@ -949,14 +946,14 @@ void main() { ...@@ -949,14 +946,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
jsonResponse: fakeUnpausedIsolate.toJson(), jsonResponse: fakeUnpausedIsolate.toJson(),
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{}).toJson(), jsonResponse: vm_service.VM.parse(<String, Object>{})!.toJson(),
), ),
listViews, listViews,
const FakeVmServiceRequest( const FakeVmServiceRequest(
...@@ -996,8 +993,8 @@ void main() { ...@@ -996,8 +993,8 @@ void main() {
final TestUsageEvent event = (globals.flutterUsage as TestUsage).events.first; final TestUsageEvent event = (globals.flutterUsage as TestUsage).events.first;
expect(event.category, 'hot'); expect(event.category, 'hot');
expect(event.parameter, 'restart'); expect(event.parameter, 'restart');
expect(event.parameters.hotEventTargetPlatform, getNameForTargetPlatform(TargetPlatform.android_arm)); expect(event.parameters?.hotEventTargetPlatform, getNameForTargetPlatform(TargetPlatform.android_arm));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Usage: () => TestUsage(), Usage: () => TestUsage(),
})); }));
...@@ -1009,14 +1006,14 @@ void main() { ...@@ -1009,14 +1006,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
jsonResponse: fakePausedIsolate.toJson(), jsonResponse: fakePausedIsolate.toJson(),
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{}).toJson(), jsonResponse: vm_service.VM.parse(<String, Object>{})!.toJson(),
), ),
const FakeVmServiceRequest( const FakeVmServiceRequest(
method: 'setIsolatePauseMode', method: 'setIsolatePauseMode',
...@@ -1072,7 +1069,7 @@ void main() { ...@@ -1072,7 +1069,7 @@ void main() {
final OperationResult result = await residentRunner.restart(fullRestart: true); final OperationResult result = await residentRunner.restart(fullRestart: true);
expect(result.isOk, true); expect(result.isOk, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner will alternative the name of the dill file uploaded for a hot restart', () => testbed.run(() async { testUsingContext('ResidentRunner will alternative the name of the dill file uploaded for a hot restart', () => testbed.run(() async {
...@@ -1082,14 +1079,14 @@ void main() { ...@@ -1082,14 +1079,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
jsonResponse: fakeUnpausedIsolate.toJson(), jsonResponse: fakeUnpausedIsolate.toJson(),
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{}).toJson(), jsonResponse: vm_service.VM.parse(<String, Object>{})!.toJson(),
), ),
listViews, listViews,
const FakeVmServiceRequest( const FakeVmServiceRequest(
...@@ -1116,14 +1113,14 @@ void main() { ...@@ -1116,14 +1113,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
jsonResponse: fakeUnpausedIsolate.toJson(), jsonResponse: fakeUnpausedIsolate.toJson(),
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{}).toJson(), jsonResponse: vm_service.VM.parse(<String, Object>{})!.toJson(),
), ),
listViews, listViews,
const FakeVmServiceRequest( const FakeVmServiceRequest(
...@@ -1150,14 +1147,14 @@ void main() { ...@@ -1150,14 +1147,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
}, },
jsonResponse: fakeUnpausedIsolate.toJson(), jsonResponse: fakeUnpausedIsolate.toJson(),
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{}).toJson(), jsonResponse: vm_service.VM.parse(<String, Object>{})!.toJson(),
), ),
listViews, listViews,
const FakeVmServiceRequest( const FakeVmServiceRequest(
...@@ -1194,7 +1191,7 @@ void main() { ...@@ -1194,7 +1191,7 @@ void main() {
await residentRunner.restart(fullRestart: true); await residentRunner.restart(fullRestart: true);
await residentRunner.restart(fullRestart: true); await residentRunner.restart(fullRestart: true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner Can handle an RPC exception from hot restart', () => testbed.run(() async { testUsingContext('ResidentRunner Can handle an RPC exception from hot restart', () => testbed.run(() async {
...@@ -1225,7 +1222,7 @@ void main() { ...@@ -1225,7 +1222,7 @@ void main() {
fastReassemble: false, fastReassemble: false,
)), )),
)); ));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Usage: () => TestUsage(), Usage: () => TestUsage(),
})); }));
...@@ -1554,7 +1551,7 @@ flutter: ...@@ -1554,7 +1551,7 @@ flutter:
await residentRunner.writeSkSL(); await residentRunner.writeSkSL();
expect(testLogger.statusText, contains('No data was received')); expect(testLogger.statusText, contains('No data was received'));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('ResidentRunner can write SkSL data to a unique file with engine revision, platform, and device name', () => testbed.run(() async { testUsingContext('ResidentRunner can write SkSL data to a unique file with engine revision, platform, and device name', () => testbed.run(() async {
...@@ -1582,7 +1579,7 @@ flutter: ...@@ -1582,7 +1579,7 @@ flutter:
'engineRevision': 'abcdefg', 'engineRevision': 'abcdefg',
'data': <String, Object>{'A': 'B'}, 'data': <String, Object>{'A': 'B'},
}); });
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystemUtils: () => FileSystemUtils( FileSystemUtils: () => FileSystemUtils(
fileSystem: globals.fs, fileSystem: globals.fs,
...@@ -1606,7 +1603,7 @@ flutter: ...@@ -1606,7 +1603,7 @@ flutter:
devtoolsHandler: createNoOpHandler, devtoolsHandler: createNoOpHandler,
); );
final Future<int> result = residentRunner.attach(); final Future<int?> result = residentRunner.attach();
expect(await result, 0); expect(await result, 0);
})); }));
...@@ -1625,13 +1622,13 @@ flutter: ...@@ -1625,13 +1622,13 @@ flutter:
final TestFlutterDevice flutterDevice = TestFlutterDevice( final TestFlutterDevice flutterDevice = TestFlutterDevice(
device, device,
); );
flutterDevice.vmService = fakeVmServiceHost.vmService; flutterDevice.vmService = fakeVmServiceHost!.vmService;
final Future<void> exitFuture = flutterDevice.exitApps(); final Future<void> exitFuture = flutterDevice.exitApps();
await expectLater(exitFuture, completes); await expectLater(exitFuture, completes);
expect(device.appStopped, true); expect(device.appStopped, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('HotRunner writes vm service file when providing debugging option', () => testbed.run(() async { testUsingContext('HotRunner writes vm service file when providing debugging option', () => testbed.run(() async {
...@@ -1652,7 +1649,7 @@ flutter: ...@@ -1652,7 +1649,7 @@ flutter:
await residentRunner.run(enableDevTools: true); await residentRunner.run(enableDevTools: true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
expect(await globals.fs.file('foo').readAsString(), testUri.toString()); expect(await globals.fs.file('foo').readAsString(), testUri.toString());
})); }));
...@@ -1856,7 +1853,7 @@ flutter: ...@@ -1856,7 +1853,7 @@ flutter:
await residentRunner.run(enableDevTools: true); await residentRunner.run(enableDevTools: true);
expect(testLogger.errorText, contains('Failed to write vmservice-out-file at foo')); expect(testLogger.errorText, contains('Failed to write vmservice-out-file at foo'));
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => ThrowingForwardingFileSystem(MemoryFileSystem.test()), FileSystem: () => ThrowingForwardingFileSystem(MemoryFileSystem.test()),
})); }));
...@@ -1879,13 +1876,13 @@ flutter: ...@@ -1879,13 +1876,13 @@ flutter:
await residentRunner.run(enableDevTools: true); await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file('foo').readAsString(), testUri.toString()); expect(await globals.fs.file('foo').readAsString(), testUri.toString());
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost?.hasRemainingExpectations, false);
})); }));
testUsingContext('FlutterDevice uses dartdevc configuration when targeting web', () async { testUsingContext('FlutterDevice uses dartdevc configuration when targeting web', () async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice(targetPlatform: TargetPlatform.web_javascript); final FakeDevice device = FakeDevice(targetPlatform: TargetPlatform.web_javascript);
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create( final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
device, device,
buildInfo: const BuildInfo( buildInfo: const BuildInfo(
BuildMode.debug, BuildMode.debug,
...@@ -1895,16 +1892,16 @@ flutter: ...@@ -1895,16 +1892,16 @@ flutter:
), ),
target: null, target: null,
platform: FakePlatform(), platform: FakePlatform(),
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler?;
expect(residentCompiler.initializeFromDill, expect(residentCompiler!.initializeFromDill,
globals.fs.path.join(getBuildDirectory(), 'fbbe6a61fb7a1de317d381f8df4814e5.cache.dill')); globals.fs.path.join(getBuildDirectory(), 'fbbe6a61fb7a1de317d381f8df4814e5.cache.dill'));
expect(residentCompiler.librariesSpec, expect(residentCompiler.librariesSpec,
globals.fs.file(globals.artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson)) globals.fs.file(globals.artifacts!.getHostArtifact(HostArtifact.flutterWebLibrariesJson))
.uri.toString()); .uri.toString());
expect(residentCompiler.targetModel, TargetModel.dartdevc); expect(residentCompiler.targetModel, TargetModel.dartdevc);
expect(residentCompiler.sdkRoot, expect(residentCompiler.sdkRoot,
'${globals.artifacts.getHostArtifact(HostArtifact.flutterWebSdk).path}/'); '${globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path}/');
expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformKernelDill'); expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformKernelDill');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(), Artifacts: () => Artifacts.test(),
...@@ -1916,7 +1913,7 @@ flutter: ...@@ -1916,7 +1913,7 @@ flutter:
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice(targetPlatform: TargetPlatform.web_javascript); final FakeDevice device = FakeDevice(targetPlatform: TargetPlatform.web_javascript);
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create( final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
device, device,
buildInfo: const BuildInfo( buildInfo: const BuildInfo(
BuildMode.debug, BuildMode.debug,
...@@ -1926,16 +1923,16 @@ flutter: ...@@ -1926,16 +1923,16 @@ flutter:
), ),
target: null, target: null,
platform: FakePlatform(), platform: FakePlatform(),
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler?;
expect(residentCompiler.initializeFromDill, expect(residentCompiler!.initializeFromDill,
globals.fs.path.join(getBuildDirectory(), '80b1a4cf4e7b90e1ab5f72022a0bc624.cache.dill')); globals.fs.path.join(getBuildDirectory(), '80b1a4cf4e7b90e1ab5f72022a0bc624.cache.dill'));
expect(residentCompiler.librariesSpec, expect(residentCompiler.librariesSpec,
globals.fs.file(globals.artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson)) globals.fs.file(globals.artifacts!.getHostArtifact(HostArtifact.flutterWebLibrariesJson))
.uri.toString()); .uri.toString());
expect(residentCompiler.targetModel, TargetModel.dartdevc); expect(residentCompiler.targetModel, TargetModel.dartdevc);
expect(residentCompiler.sdkRoot, expect(residentCompiler.sdkRoot,
'${globals.artifacts.getHostArtifact(HostArtifact.flutterWebSdk).path}/'); '${globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path}/');
expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformSoundKernelDill'); expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformSoundKernelDill');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(), Artifacts: () => Artifacts.test(),
...@@ -1947,7 +1944,7 @@ flutter: ...@@ -1947,7 +1944,7 @@ flutter:
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice(); final FakeDevice device = FakeDevice();
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create( final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
device, device,
buildInfo: const BuildInfo( buildInfo: const BuildInfo(
BuildMode.debug, BuildMode.debug,
...@@ -1955,10 +1952,10 @@ flutter: ...@@ -1955,10 +1952,10 @@ flutter:
treeShakeIcons: false, treeShakeIcons: false,
extraFrontEndOptions: <String>[], extraFrontEndOptions: <String>[],
), ),
target: null, platform: null, target: null, platform: FakePlatform(),
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler?;
expect(residentCompiler.extraFrontEndOptions, expect(residentCompiler!.extraFrontEndOptions,
contains('--flutter-widget-cache')); contains('--flutter-widget-cache'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(), Artifacts: () => Artifacts.test(),
...@@ -1972,7 +1969,7 @@ flutter: ...@@ -1972,7 +1969,7 @@ flutter:
final FakeDevice device = FakeDevice(); final FakeDevice device = FakeDevice();
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create( final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
device, device,
buildInfo: const BuildInfo( buildInfo: const BuildInfo(
BuildMode.debug, BuildMode.debug,
...@@ -1980,10 +1977,10 @@ flutter: ...@@ -1980,10 +1977,10 @@ flutter:
treeShakeIcons: false, treeShakeIcons: false,
extraFrontEndOptions: <String>[], extraFrontEndOptions: <String>[],
), ),
target: null, platform: null, target: null, platform: FakePlatform(),
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler?;
expect(residentCompiler.extraFrontEndOptions, expect(residentCompiler!.extraFrontEndOptions,
contains('--enable-experiment=alternative-invalidation-strategy')); contains('--enable-experiment=alternative-invalidation-strategy'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(), Artifacts: () => Artifacts.test(),
...@@ -1995,7 +1992,7 @@ flutter: ...@@ -1995,7 +1992,7 @@ flutter:
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice(); final FakeDevice device = FakeDevice();
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create( final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
device, device,
buildInfo: const BuildInfo( buildInfo: const BuildInfo(
BuildMode.debug, BuildMode.debug,
...@@ -2004,10 +2001,10 @@ flutter: ...@@ -2004,10 +2001,10 @@ flutter:
extraFrontEndOptions: <String>[], extraFrontEndOptions: <String>[],
initializeFromDill: '/foo/bar.dill', initializeFromDill: '/foo/bar.dill',
), ),
target: null, platform: null, target: null, platform: FakePlatform(),
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler?;
expect(residentCompiler.initializeFromDill, '/foo/bar.dill'); expect(residentCompiler!.initializeFromDill, '/foo/bar.dill');
expect(residentCompiler.assumeInitializeFromDillUpToDate, false); expect(residentCompiler.assumeInitializeFromDillUpToDate, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(), Artifacts: () => Artifacts.test(),
...@@ -2019,7 +2016,7 @@ flutter: ...@@ -2019,7 +2016,7 @@ flutter:
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice(); final FakeDevice device = FakeDevice();
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create( final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
device, device,
buildInfo: const BuildInfo( buildInfo: const BuildInfo(
BuildMode.debug, BuildMode.debug,
...@@ -2028,10 +2025,10 @@ flutter: ...@@ -2028,10 +2025,10 @@ flutter:
extraFrontEndOptions: <String>[], extraFrontEndOptions: <String>[],
assumeInitializeFromDillUpToDate: true, assumeInitializeFromDillUpToDate: true,
), ),
target: null, platform: null, target: null, platform: FakePlatform(),
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler?;
expect(residentCompiler.assumeInitializeFromDillUpToDate, true); expect(residentCompiler!.assumeInitializeFromDillUpToDate, true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(), Artifacts: () => Artifacts.test(),
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
...@@ -2042,7 +2039,7 @@ flutter: ...@@ -2042,7 +2039,7 @@ flutter:
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice() final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService(); ..dds = DartDevelopmentService();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, dds.UriConverter uriConverter}) { ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true, bool ipv6 = false, Uri? serviceUri, List<String> cachedUserTags = const <String>[], dds.UriConverter? uriConverter}) {
expect(uri, Uri(scheme: 'foo', host: 'bar')); expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isTrue); expect(enableAuthCodes, isTrue);
expect(ipv6, isFalse); expect(ipv6, isFalse);
...@@ -2062,7 +2059,7 @@ flutter: ...@@ -2062,7 +2059,7 @@ flutter:
runZonedGuarded(() { runZonedGuarded(() {
flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete()); flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete());
}, (Object e, StackTrace st) { }, (Object e, StackTrace st) {
expect(e is ToolExit, true); expect(e, isA<ToolExit>());
expect((e as ToolExit).message, expect((e as ToolExit).message,
contains('Existing VM service clients prevent DDS from taking control.', contains('Existing VM service clients prevent DDS from taking control.',
)); ));
...@@ -2075,14 +2072,14 @@ flutter: ...@@ -2075,14 +2072,14 @@ flutter:
} }
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions? compression,
Device device, Device? device,
Logger logger, required Logger logger,
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService, }) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
})); }));
...@@ -2091,7 +2088,7 @@ flutter: ...@@ -2091,7 +2088,7 @@ flutter:
final FakeDevice device = FakeDevice() final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService(); ..dds = DartDevelopmentService();
final Completer<void>done = Completer<void>(); final Completer<void>done = Completer<void>();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, dds.UriConverter uriConverter}) async { ddsLauncherCallback = (Uri uri, {bool enableAuthCodes = true, bool ipv6 = false, Uri? serviceUri, List<String> cachedUserTags = const <String>[], dds.UriConverter? uriConverter}) async {
expect(uri, Uri(scheme: 'foo', host: 'bar')); expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isFalse); expect(enableAuthCodes, isFalse);
expect(ipv6, isTrue); expect(ipv6, isTrue);
...@@ -2099,7 +2096,7 @@ flutter: ...@@ -2099,7 +2096,7 @@ flutter:
expect(cachedUserTags, isEmpty); expect(cachedUserTags, isEmpty);
expect(uriConverter, isNull); expect(uriConverter, isNull);
done.complete(); done.complete();
return null; return FakeDartDevelopmentService();
}; };
final TestFlutterDevice flutterDevice = TestFlutterDevice( final TestFlutterDevice flutterDevice = TestFlutterDevice(
device, device,
...@@ -2109,14 +2106,14 @@ flutter: ...@@ -2109,14 +2106,14 @@ flutter:
await done.future; await done.future;
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions? compression,
Device device, Device? device,
Logger logger, required Logger logger,
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService, }) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
})); }));
...@@ -2125,7 +2122,14 @@ flutter: ...@@ -2125,7 +2122,14 @@ flutter:
final FakeDevice device = FakeDevice() final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService(); ..dds = DartDevelopmentService();
final Completer<void>done = Completer<void>(); final Completer<void>done = Completer<void>();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, dds.UriConverter uriConverter}) async { ddsLauncherCallback = (
Uri uri, {
bool enableAuthCodes = false,
bool ipv6 = false,
Uri? serviceUri,
List<String> cachedUserTags = const <String>[],
dds.UriConverter? uriConverter,
}) async {
expect(uri, Uri(scheme: 'foo', host: 'bar')); expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isFalse); expect(enableAuthCodes, isFalse);
expect(ipv6, isTrue); expect(ipv6, isTrue);
...@@ -2133,7 +2137,7 @@ flutter: ...@@ -2133,7 +2137,7 @@ flutter:
expect(cachedUserTags, isEmpty); expect(cachedUserTags, isEmpty);
expect(uriConverter, isNotNull); expect(uriConverter, isNotNull);
done.complete(); done.complete();
return null; return FakeDartDevelopmentService();
}; };
final TestFlutterDevice flutterDevice = TestFlutterDevice( final TestFlutterDevice flutterDevice = TestFlutterDevice(
device, device,
...@@ -2143,14 +2147,14 @@ flutter: ...@@ -2143,14 +2147,14 @@ flutter:
await done.future; await done.future;
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
Device device, Device? device,
Logger logger, required Logger logger,
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService, }) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
dds.UriConverter: () => (String uri) => 'test', dds.UriConverter: () => (String uri) => 'test',
})); }));
...@@ -2159,7 +2163,14 @@ flutter: ...@@ -2159,7 +2163,14 @@ flutter:
// See https://github.com/flutter/flutter/issues/72385 for context. // See https://github.com/flutter/flutter/issues/72385 for context.
final FakeDevice device = FakeDevice() final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService(); ..dds = DartDevelopmentService();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags, dds.UriConverter uriConverter}) { ddsLauncherCallback = (
Uri uri, {
bool enableAuthCodes = false,
bool ipv6 = false,
Uri? serviceUri,
List<String> cachedUserTags = const <String>[],
dds.UriConverter? uriConverter,
}) {
expect(uri, Uri(scheme: 'foo', host: 'bar')); expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isTrue); expect(enableAuthCodes, isTrue);
expect(ipv6, isFalse); expect(ipv6, isFalse);
...@@ -2177,7 +2188,7 @@ flutter: ...@@ -2177,7 +2188,7 @@ flutter:
runZonedGuarded(() { runZonedGuarded(() {
flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete()); flutterDevice.connect(allowExistingDdsInstance: true).then((_) => done.complete());
}, (Object e, StackTrace st) { }, (Object e, StackTrace st) {
expect(e is StateError, true); expect(e, isA<StateError>());
expect((e as StateError).message, contains('No URI')); expect((e as StateError).message, contains('No URI'));
expect(testLogger.errorText, contains( expect(testLogger.errorText, contains(
'DDS has failed to start and there is not an existing DDS instance', 'DDS has failed to start and there is not an existing DDS instance',
...@@ -2191,14 +2202,14 @@ flutter: ...@@ -2191,14 +2202,14 @@ flutter:
} }
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
Device device, Device? device,
Logger logger, required Logger logger,
}) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService, }) async => FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService,
})); }));
...@@ -2222,7 +2233,7 @@ flutter: ...@@ -2222,7 +2233,7 @@ flutter:
); );
await residentRunner.cleanupAtFinish(); await residentRunner.cleanupAtFinish();
expect((residentRunner.residentDevtoolsHandler as NoOpDevtoolsHandler).wasShutdown, true); expect((residentRunner.residentDevtoolsHandler! as NoOpDevtoolsHandler).wasShutdown, true);
})); }));
testUsingContext('HotRunner sets asset directory when first evict assets', () => testbed.run(() async { testUsingContext('HotRunner sets asset directory when first evict assets', () => testbed.run(() async {
...@@ -2241,12 +2252,12 @@ flutter: ...@@ -2241,12 +2252,12 @@ flutter:
devtoolsHandler: createNoOpHandler, devtoolsHandler: createNoOpHandler,
); );
(flutterDevice.devFS as FakeDevFS).assetPathsToEvict = <String>{'asset'}; (flutterDevice.devFS! as FakeDevFS).assetPathsToEvict = <String>{'asset'};
expect(flutterDevice.devFS.hasSetAssetDirectory, false); expect(flutterDevice.devFS!.hasSetAssetDirectory, isFalse);
await (residentRunner as HotRunner).evictDirtyAssets(); await (residentRunner as HotRunner).evictDirtyAssets();
expect(flutterDevice.devFS.hasSetAssetDirectory, true); expect(flutterDevice.devFS!.hasSetAssetDirectory, isTrue);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost!.hasRemainingExpectations, isFalse);
})); }));
testUsingContext('HotRunner sets asset directory when first evict shaders', () => testbed.run(() async { testUsingContext('HotRunner sets asset directory when first evict shaders', () => testbed.run(() async {
...@@ -2265,12 +2276,12 @@ flutter: ...@@ -2265,12 +2276,12 @@ flutter:
devtoolsHandler: createNoOpHandler, devtoolsHandler: createNoOpHandler,
); );
(flutterDevice.devFS as FakeDevFS).shaderPathsToEvict = <String>{'foo.frag'}; (flutterDevice.devFS! as FakeDevFS).shaderPathsToEvict = <String>{'foo.frag'};
expect(flutterDevice.devFS.hasSetAssetDirectory, false); expect(flutterDevice.devFS!.hasSetAssetDirectory, false);
await (residentRunner as HotRunner).evictDirtyAssets(); await (residentRunner as HotRunner).evictDirtyAssets();
expect(flutterDevice.devFS.hasSetAssetDirectory, true); expect(flutterDevice.devFS!.hasSetAssetDirectory, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost!.hasRemainingExpectations, false);
})); }));
testUsingContext('HotRunner does not sets asset directory when no assets to evict', () => testbed.run(() async { testUsingContext('HotRunner does not sets asset directory when no assets to evict', () => testbed.run(() async {
...@@ -2286,10 +2297,10 @@ flutter: ...@@ -2286,10 +2297,10 @@ flutter:
devtoolsHandler: createNoOpHandler, devtoolsHandler: createNoOpHandler,
); );
expect(flutterDevice.devFS.hasSetAssetDirectory, false); expect(flutterDevice.devFS!.hasSetAssetDirectory, false);
await (residentRunner as HotRunner).evictDirtyAssets(); await (residentRunner as HotRunner).evictDirtyAssets();
expect(flutterDevice.devFS.hasSetAssetDirectory, false); expect(flutterDevice.devFS!.hasSetAssetDirectory, false);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost!.hasRemainingExpectations, false);
})); }));
testUsingContext('HotRunner does not set asset directory if it has been set before', () => testbed.run(() async { testUsingContext('HotRunner does not set asset directory if it has been set before', () => testbed.run(() async {
...@@ -2307,15 +2318,25 @@ flutter: ...@@ -2307,15 +2318,25 @@ flutter:
devtoolsHandler: createNoOpHandler, devtoolsHandler: createNoOpHandler,
); );
(flutterDevice.devFS as FakeDevFS).assetPathsToEvict = <String>{'asset'}; (flutterDevice.devFS! as FakeDevFS).assetPathsToEvict = <String>{'asset'};
flutterDevice.devFS.hasSetAssetDirectory = true; flutterDevice.devFS!.hasSetAssetDirectory = true;
await (residentRunner as HotRunner).evictDirtyAssets(); await (residentRunner as HotRunner).evictDirtyAssets();
expect(flutterDevice.devFS.hasSetAssetDirectory, true); expect(flutterDevice.devFS!.hasSetAssetDirectory, true);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost!.hasRemainingExpectations, false);
})); }));
} }
// NOTE: implements [dds.DartDevelopmentService] and NOT [DartDevelopmentService]
// from package:flutter_tools.
class FakeDartDevelopmentService extends Fake implements dds.DartDevelopmentService {
@override
Future<void> get done => Future<void>.value();
@override
Uri? get uri => null;
}
class FakeDartDevelopmentServiceException implements dds.DartDevelopmentServiceException { class FakeDartDevelopmentServiceException implements dds.DartDevelopmentServiceException {
FakeDartDevelopmentServiceException({this.message = defaultMessage}); FakeDartDevelopmentServiceException({this.message = defaultMessage});
...@@ -2328,18 +2349,17 @@ class FakeDartDevelopmentServiceException implements dds.DartDevelopmentServiceE ...@@ -2328,18 +2349,17 @@ class FakeDartDevelopmentServiceException implements dds.DartDevelopmentServiceE
} }
class TestFlutterDevice extends FlutterDevice { class TestFlutterDevice extends FlutterDevice {
TestFlutterDevice(Device device, { Stream<Uri> observatoryUris }) TestFlutterDevice(super.device, { Stream<Uri>? observatoryUris })
: super(device, buildInfo: BuildInfo.debug, developmentShaderCompiler: const FakeShaderCompiler()) { : _observatoryUris = observatoryUris, super(buildInfo: BuildInfo.debug, developmentShaderCompiler: const FakeShaderCompiler());
_observatoryUris = observatoryUris;
} final Stream<Uri>? _observatoryUris;
@override @override
Stream<Uri> get observatoryUris => _observatoryUris; Stream<Uri> get observatoryUris => _observatoryUris!;
Stream<Uri> _observatoryUris;
} }
class ThrowingForwardingFileSystem extends ForwardingFileSystem { class ThrowingForwardingFileSystem extends ForwardingFileSystem {
ThrowingForwardingFileSystem(FileSystem delegate) : super(delegate); ThrowingForwardingFileSystem(super.delegate);
@override @override
File file(dynamic path) { File file(dynamic path) {
...@@ -2351,19 +2371,19 @@ class ThrowingForwardingFileSystem extends ForwardingFileSystem { ...@@ -2351,19 +2371,19 @@ class ThrowingForwardingFileSystem extends ForwardingFileSystem {
} }
class FakeFlutterDevice extends Fake implements FlutterDevice { class FakeFlutterDevice extends Fake implements FlutterDevice {
FakeVmServiceHost Function() vmServiceHost; FakeVmServiceHost? Function()? vmServiceHost;
Uri testUri; Uri? testUri;
UpdateFSReport report = UpdateFSReport( UpdateFSReport report = UpdateFSReport(
success: true, success: true,
invalidatedSourcesCount: 1, invalidatedSourcesCount: 1,
); );
Exception reportError; Exception? reportError;
Exception runColdError; Exception? runColdError;
int runHotCode = 0; int runHotCode = 0;
int runColdCode = 0; int runColdCode = 0;
@override @override
ResidentCompiler generator; ResidentCompiler? generator;
@override @override
DevelopmentShaderCompiler get developmentShaderCompiler => const FakeShaderCompiler(); DevelopmentShaderCompiler get developmentShaderCompiler => const FakeShaderCompiler();
...@@ -2372,21 +2392,21 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { ...@@ -2372,21 +2392,21 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
TargetPlatform get targetPlatform => TargetPlatform.android; TargetPlatform get targetPlatform => TargetPlatform.android;
@override @override
Stream<Uri> get observatoryUris => Stream<Uri>.value(testUri); Stream<Uri?> get observatoryUris => Stream<Uri?>.value(testUri);
@override @override
FlutterVmService get vmService => vmServiceHost?.call()?.vmService; FlutterVmService? get vmService => vmServiceHost?.call()?.vmService;
DevFS _devFS; DevFS? _devFS;
@override @override
DevFS get devFS => _devFS; DevFS? get devFS => _devFS;
@override @override
set devFS(DevFS value) { } set devFS(DevFS? value) { }
@override @override
Device device; Device? device;
@override @override
Future<void> stopEchoingDeviceLog() async { } Future<void> stopEchoingDeviceLog() async { }
...@@ -2396,55 +2416,55 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { ...@@ -2396,55 +2416,55 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
@override @override
Future<Uri> setupDevFS(String fsName, Directory rootDirectory) async { Future<Uri> setupDevFS(String fsName, Directory rootDirectory) async {
return testUri; return testUri!;
} }
@override @override
Future<int> runHot({HotRunner hotRunner, String route}) async { Future<int> runHot({required HotRunner hotRunner, String? route}) async {
return runHotCode; return runHotCode;
} }
@override @override
Future<int> runCold({ColdRunner coldRunner, String route}) async { Future<int> runCold({required ColdRunner coldRunner, String? route}) async {
if (runColdError != null) { if (runColdError != null) {
throw runColdError; throw runColdError!;
} }
return runColdCode; return runColdCode;
} }
@override @override
Future<void> connect({ Future<void> connect({
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
int hostVmServicePort, int? hostVmServicePort,
int ddsPort, int? ddsPort,
bool disableServiceAuthCodes = false, bool disableServiceAuthCodes = false,
bool enableDds = true, bool enableDds = true,
bool cacheStartupProfile = false, bool cacheStartupProfile = false,
@required bool allowExistingDdsInstance, required bool allowExistingDdsInstance,
bool ipv6 = false, bool ipv6 = false,
}) async { } }) async { }
@override @override
Future<UpdateFSReport> updateDevFS({ Future<UpdateFSReport> updateDevFS({
Uri mainUri, required Uri mainUri,
String target, String? target,
AssetBundle bundle, AssetBundle? bundle,
DateTime firstBuildTime, DateTime? firstBuildTime,
bool bundleFirstUpload = false, bool bundleFirstUpload = false,
bool bundleDirty = false, bool bundleDirty = false,
bool fullRestart = false, bool fullRestart = false,
String projectRootPath, String? projectRootPath,
String pathToReload, required String pathToReload,
String dillOutputPath, required String dillOutputPath,
List<Uri> invalidatedFiles, required List<Uri> invalidatedFiles,
PackageConfig packageConfig, required PackageConfig packageConfig,
}) async { }) async {
if (reportError != null) { if (reportError != null) {
throw reportError; throw reportError!;
} }
return report; return report;
} }
...@@ -2455,25 +2475,25 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { ...@@ -2455,25 +2475,25 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
class FakeDelegateFlutterDevice extends FlutterDevice { class FakeDelegateFlutterDevice extends FlutterDevice {
FakeDelegateFlutterDevice( FakeDelegateFlutterDevice(
Device device, super.device,
BuildInfo buildInfo, BuildInfo buildInfo,
ResidentCompiler residentCompiler, ResidentCompiler residentCompiler,
this.fakeDevFS, this.fakeDevFS,
) : super(device, buildInfo: buildInfo, generator: residentCompiler, developmentShaderCompiler: const FakeShaderCompiler()); ) : super(buildInfo: buildInfo, generator: residentCompiler, developmentShaderCompiler: const FakeShaderCompiler());
@override @override
Future<void> connect({ Future<void> connect({
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
bool enableDds = true, bool enableDds = true,
bool cacheStartupProfile = false, bool cacheStartupProfile = false,
bool disableServiceAuthCodes = false, bool disableServiceAuthCodes = false,
bool ipv6 = false, bool ipv6 = false,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
int hostVmServicePort, int? hostVmServicePort,
int ddsPort, int? ddsPort,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
bool allowExistingDdsInstance = false, bool allowExistingDdsInstance = false,
}) async { } }) async { }
...@@ -2481,27 +2501,27 @@ class FakeDelegateFlutterDevice extends FlutterDevice { ...@@ -2481,27 +2501,27 @@ class FakeDelegateFlutterDevice extends FlutterDevice {
final DevFS fakeDevFS; final DevFS fakeDevFS;
@override @override
DevFS get devFS => fakeDevFS; DevFS? get devFS => fakeDevFS;
@override @override
set devFS(DevFS value) {} set devFS(DevFS? value) {}
} }
class FakeResidentCompiler extends Fake implements ResidentCompiler { class FakeResidentCompiler extends Fake implements ResidentCompiler {
CompilerOutput nextOutput; CompilerOutput? nextOutput;
bool didSuppressErrors = false; bool didSuppressErrors = false;
@override @override
Future<CompilerOutput> recompile( Future<CompilerOutput?> recompile(
Uri mainUri, Uri mainUri,
List<Uri> invalidatedFiles, { List<Uri>? invalidatedFiles, {
@required String outputPath, required String outputPath,
@required PackageConfig packageConfig, required PackageConfig packageConfig,
@required String projectRootPath, String? projectRootPath,
@required FileSystem fs, required FileSystem fs,
bool suppressErrors = false, bool suppressErrors = false,
bool checkDartPluginRegistry = false, bool checkDartPluginRegistry = false,
File dartPluginRegistrant, File? dartPluginRegistrant,
}) async { }) async {
didSuppressErrors = suppressErrors; didSuppressErrors = suppressErrors;
return nextOutput ?? const CompilerOutput('foo.dill', 0, <Uri>[]); return nextOutput ?? const CompilerOutput('foo.dill', 0, <Uri>[]);
...@@ -2517,14 +2537,14 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { ...@@ -2517,14 +2537,14 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
class FakeProjectFileInvalidator extends Fake implements ProjectFileInvalidator { class FakeProjectFileInvalidator extends Fake implements ProjectFileInvalidator {
@override @override
Future<InvalidationResult> findInvalidated({ Future<InvalidationResult> findInvalidated({
@required DateTime lastCompiled, required DateTime? lastCompiled,
@required List<Uri> urisToMonitor, required List<Uri> urisToMonitor,
@required String packagesPath, required String packagesPath,
@required PackageConfig packageConfig, required PackageConfig packageConfig,
bool asyncScanning = false, bool asyncScanning = false,
}) async { }) async {
return InvalidationResult( return InvalidationResult(
packageConfig: packageConfig ?? PackageConfig.empty, packageConfig: packageConfig,
uris: <Uri>[Uri.parse('file:///hello_world/main.dart'), uris: <Uri>[Uri.parse('file:///hello_world/main.dart'),
]); ]);
} }
...@@ -2580,7 +2600,7 @@ class FakeDevice extends Fake implements Device { ...@@ -2580,7 +2600,7 @@ class FakeDevice extends Fake implements Device {
String get name => 'FakeDevice'; String get name => 'FakeDevice';
@override @override
DartDevelopmentService dds; late DartDevelopmentService dds;
@override @override
Future<void> dispose() async { Future<void> dispose() async {
...@@ -2588,7 +2608,7 @@ class FakeDevice extends Fake implements Device { ...@@ -2588,7 +2608,7 @@ class FakeDevice extends Fake implements Device {
} }
@override @override
Future<bool> stopApp(covariant ApplicationPackage app, {String userIdentifier}) async { Future<bool> stopApp(covariant ApplicationPackage? app, {String? userIdentifier}) async {
appStopped = true; appStopped = true;
return true; return true;
} }
...@@ -2603,7 +2623,7 @@ class FakeDevice extends Fake implements Device { ...@@ -2603,7 +2623,7 @@ class FakeDevice extends Fake implements Device {
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
covariant ApplicationPackage app, covariant ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) => NoOpDeviceLogReader(name); }) => NoOpDeviceLogReader(name);
...@@ -2613,10 +2633,10 @@ class FakeDevice extends Fake implements Device { ...@@ -2613,10 +2633,10 @@ class FakeDevice extends Fake implements Device {
class FakeDevFS extends Fake implements DevFS { class FakeDevFS extends Fake implements DevFS {
@override @override
DateTime lastCompiled = DateTime(2000); DateTime? lastCompiled = DateTime(2000);
@override @override
PackageConfig lastPackageConfig = PackageConfig.empty; PackageConfig? lastPackageConfig = PackageConfig.empty;
@override @override
List<Uri> sources = <Uri>[]; List<Uri> sources = <Uri>[];
...@@ -2653,22 +2673,22 @@ class FakeDevFS extends Fake implements DevFS { ...@@ -2653,22 +2673,22 @@ class FakeDevFS extends Fake implements DevFS {
@override @override
Future<UpdateFSReport> update({ Future<UpdateFSReport> update({
@required Uri mainUri, required Uri mainUri,
@required ResidentCompiler generator, required ResidentCompiler generator,
@required bool trackWidgetCreation, required bool trackWidgetCreation,
@required String pathToReload, required String pathToReload,
@required List<Uri> invalidatedFiles, required List<Uri> invalidatedFiles,
@required PackageConfig packageConfig, required PackageConfig packageConfig,
@required String dillOutputPath, required String dillOutputPath,
@required DevelopmentShaderCompiler shaderCompiler, required DevelopmentShaderCompiler shaderCompiler,
DevFSWriter devFSWriter, DevFSWriter? devFSWriter,
String target, String? target,
AssetBundle bundle, AssetBundle? bundle,
DateTime firstBuildTime, DateTime? firstBuildTime,
bool bundleFirstUpload = false, bool bundleFirstUpload = false,
bool fullRestart = false, bool fullRestart = false,
String projectRootPath, String? projectRootPath,
File dartPluginRegistrant, File? dartPluginRegistrant,
}) async { }) async {
return nextUpdateReport; return nextUpdateReport;
} }
...@@ -2678,7 +2698,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -2678,7 +2698,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler(TargetPlatform platform, { @required bool enableImpeller }) { } void configureCompiler(TargetPlatform? platform, { required bool enableImpeller }) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
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