diff --git a/webdev/bin/webdev.dart b/webdev/bin/webdev.dart index 7187675b2..42d8d6c64 100644 --- a/webdev/bin/webdev.dart +++ b/webdev/bin/webdev.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'dart:io'; import 'dart:isolate'; @@ -52,4 +50,4 @@ Future main(List args) async { } } -String get _boldApp => styleBold.wrap(appName); +String get _boldApp => styleBold.wrap(appName)!; diff --git a/webdev/lib/src/command/daemon_command.dart b/webdev/lib/src/command/daemon_command.dart index 5e04fc2ca..420262e89 100644 --- a/webdev/lib/src/command/daemon_command.dart +++ b/webdev/lib/src/command/daemon_command.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -69,8 +67,8 @@ class DaemonCommand extends Command { // Validate the pubspec first to ensure we are in a Dart project. var pubspecLock = await readPubspecLock(configuration); - Daemon daemon; - DevWorkflow workflow; + Daemon? daemon; + DevWorkflow? workflow; var cancelCount = 0; var cancelSub = StreamGroup.merge([ ProcessSignal.sigint.watch(), @@ -100,8 +98,9 @@ class DaemonCommand extends Command { }); daemon.registerDomain(daemonDomain); var buildOptions = buildRunnerArgs(pubspecLock, configuration); + var extraArgs = argResults?.rest ?? []; var directoryArgs = - argResults.rest.where((arg) => !arg.startsWith('-')).toList(); + extraArgs.where((arg) => !arg.startsWith('-')).toList(); var targetPorts = parseDirectoryArgs(directoryArgs, basePort: await findUnusedPort()); validateLaunchApps(configuration.launchApps, targetPorts.keys); diff --git a/webdev/lib/src/command/serve_command.dart b/webdev/lib/src/command/serve_command.dart index caefd754c..4111cc612 100644 --- a/webdev/lib/src/command/serve_command.dart +++ b/webdev/lib/src/command/serve_command.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'package:args/args.dart'; @@ -99,9 +97,9 @@ refresh: Performs a full page refresh. // Forward remaining arguments as Build Options to the Daemon. // This isn't documented. Should it be advertised? var buildOptions = buildRunnerArgs(pubspecLock, configuration) - ..addAll(argResults.rest.where((arg) => arg.startsWith('-')).toList()); - var directoryArgs = - argResults.rest.where((arg) => !arg.startsWith('-')).toList(); + ..addAll(argResults!.rest.where((arg) => arg.startsWith('-')).toList()); + var extraArgs = argResults?.rest ?? []; + var directoryArgs = extraArgs.where((arg) => !arg.startsWith('-')).toList(); var targetPorts = parseDirectoryArgs(directoryArgs); validateLaunchApps(configuration.launchApps, targetPorts.keys); diff --git a/webdev/lib/src/daemon/app_domain.dart b/webdev/lib/src/daemon/app_domain.dart index 30169f831..d67f77329 100644 --- a/webdev/lib/src/daemon/app_domain.dart +++ b/webdev/lib/src/daemon/app_domain.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -21,7 +19,7 @@ import 'utilites.dart'; /// A collection of method and events relevant to the running application. class AppDomain extends Domain { bool _isShutdown = false; - int _buildProgressEventId; + int? _buildProgressEventId; var _progressEventId = 0; final _appStates = {}; @@ -58,7 +56,7 @@ class AppDomain extends Domain { } void _handleAppConnections(WebDevServer server) async { - var dwds = server.dwds; + var dwds = server.dwds!; // The connection is established right before `main()` is called. await for (var appConnection in dwds.connectedApps) { var debugConnection = await dwds.debugConnection(appConnection); @@ -94,7 +92,7 @@ class AppDomain extends Domain { var stdOutSub = vmService.onStdoutEvent.listen((log) { sendEvent('app.log', { 'appId': appId, - 'log': utf8.decode(base64.decode(log.bytes)), + 'log': utf8.decode(base64.decode(log.bytes!)), }); }); sendEvent('app.debugPort', { @@ -129,19 +127,19 @@ class AppDomain extends Domain { _initialize(serverManager); } - Future> _callServiceExtension( + Future?> _callServiceExtension( Map args) async { var appId = getStringArg(args, 'appId', required: true); var appState = _appStates[appId]; if (appState == null) { throw ArgumentError.value(appId, 'appId', 'Not found'); } - var methodName = getStringArg(args, 'methodName', required: true); + var methodName = getStringArg(args, 'methodName', required: true)!; var params = args['params'] != null ? (args['params'] as Map) : {}; - var response = - await appState.vmService.callServiceExtension(methodName, args: params); + var response = await appState.vmService! + .callServiceExtension(methodName, args: params); return response.json; } @@ -168,7 +166,7 @@ class AppDomain extends Domain { 'message': 'Performing hot restart...', 'progressId': 'hot.restart', }); - var response = await appState.vmService.callServiceExtension('hotRestart'); + var response = await appState.vmService!.callServiceExtension('hotRestart'); sendEvent('app.progress', { 'appId': appId, 'id': '$_progressEventId', @@ -193,7 +191,7 @@ class AppDomain extends Domain { } // Note that this triggers the daemon to shutdown as we listen for the // tabConnection to close to initiate a shutdown. - await appState._debugConnection?.close(); + await appState._debugConnection.close(); // Wait for the daemon to gracefully shutdown before sending success. await daemon.onExit; return true; @@ -216,15 +214,15 @@ class _AppState { bool _isDisposed = false; - VmService get vmService => _debugConnection?.vmService; + VmService? get vmService => _debugConnection.vmService; _AppState(this._debugConnection, this._resultSub, this._stdOutSub); void dispose() { if (_isDisposed) return; _isDisposed = true; - _stdOutSub?.cancel(); - _resultSub?.cancel(); - _debugConnection?.close(); + _stdOutSub.cancel(); + _resultSub.cancel(); + _debugConnection.close(); } } diff --git a/webdev/lib/src/serve/dev_workflow.dart b/webdev/lib/src/serve/dev_workflow.dart index a50233b4c..74c6781c6 100644 --- a/webdev/lib/src/serve/dev_workflow.dart +++ b/webdev/lib/src/serve/dev_workflow.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'dart:io'; @@ -57,7 +55,7 @@ String _uriForLaunchApp(String launchApp, ServerManager serverManager) { .toString(); } -Future _startChrome( +Future _startChrome( Configuration configuration, ServerManager serverManager, BuildDaemonClient client, @@ -99,7 +97,7 @@ Future _startServerManager( for (var target in targetPorts.keys) { serverOptions.add(ServerOptions( configuration, - targetPorts[target], + targetPorts[target]!, target, assetPort, )); @@ -125,7 +123,7 @@ void _registerBuildTargets( ) { // Register a target for each serve target. for (var target in targetPorts.keys) { - OutputLocation outputLocation; + OutputLocation? outputLocation; if (configuration.outputPath != null && (configuration.outputInput == null || target == configuration.outputInput)) { @@ -147,7 +145,7 @@ void _registerBuildTargets( ..hoist = false); client.registerBuildTarget(DefaultBuildTarget((b) => b ..target = '' - ..outputLocation = outputLocation?.toBuilder())); + ..outputLocation = outputLocation.toBuilder())); } } @@ -158,10 +156,10 @@ void _registerBuildTargets( class DevWorkflow { final _doneCompleter = Completer(); final BuildDaemonClient _client; - final Chrome _chrome; + final Chrome? _chrome; final ServerManager serverManager; - StreamSubscription _resultsSub; + StreamSubscription? _resultsSub; final _wrapWidth = stdout.hasTerminal ? stdout.terminalColumns - 8 : 72; @@ -208,8 +206,8 @@ class DevWorkflow { Future shutDown() async { await _resultsSub?.cancel(); await _chrome?.close(); - await _client?.close(); - await serverManager?.stop(); + await _client.close(); + await serverManager.stop(); if (!_doneCompleter.isCompleted) _doneCompleter.complete(); } } diff --git a/webdev/lib/src/webdev_command_runner.dart b/webdev/lib/src/webdev_command_runner.dart index 54525d9b4..2f5af323f 100644 --- a/webdev/lib/src/webdev_command_runner.dart +++ b/webdev/lib/src/webdev_command_runner.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'package:args/args.dart'; @@ -18,7 +16,7 @@ import 'version.dart'; export 'pubspec.dart' show PackageException; export 'util.dart' show appName; -Future run(List args) => _CommandRunner().run(args); +Future run(List args) async => (await _CommandRunner().run(args))!; class _CommandRunner extends CommandRunner { _CommandRunner() : super(appName, 'A tool to develop Dart web projects.') {