22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // @dart = 2.9
6-
75import 'dart:async' ;
86import 'dart:convert' ;
97import 'dart:io' ;
@@ -21,7 +19,7 @@ import 'utilites.dart';
2119/// A collection of method and events relevant to the running application.
2220class AppDomain extends Domain {
2321 bool _isShutdown = false ;
24- int _buildProgressEventId;
22+ int ? _buildProgressEventId;
2523 var _progressEventId = 0 ;
2624
2725 final _appStates = < String , _AppState > {};
@@ -58,7 +56,7 @@ class AppDomain extends Domain {
5856 }
5957
6058 void _handleAppConnections (WebDevServer server) async {
61- var dwds = server.dwds;
59+ var dwds = server.dwds! ;
6260 // The connection is established right before `main()` is called.
6361 await for (var appConnection in dwds.connectedApps) {
6462 var debugConnection = await dwds.debugConnection (appConnection);
@@ -94,7 +92,7 @@ class AppDomain extends Domain {
9492 var stdOutSub = vmService.onStdoutEvent.listen ((log) {
9593 sendEvent ('app.log' , {
9694 'appId' : appId,
97- 'log' : utf8.decode (base64.decode (log.bytes)),
95+ 'log' : utf8.decode (base64.decode (log.bytes! )),
9896 });
9997 });
10098 sendEvent ('app.debugPort' , {
@@ -129,19 +127,19 @@ class AppDomain extends Domain {
129127 _initialize (serverManager);
130128 }
131129
132- Future <Map <String , dynamic >> _callServiceExtension (
130+ Future <Map <String , dynamic >? > _callServiceExtension (
133131 Map <String , dynamic > args) async {
134132 var appId = getStringArg (args, 'appId' , required : true );
135133 var appState = _appStates[appId];
136134 if (appState == null ) {
137135 throw ArgumentError .value (appId, 'appId' , 'Not found' );
138136 }
139- var methodName = getStringArg (args, 'methodName' , required : true );
137+ var methodName = getStringArg (args, 'methodName' , required : true )! ;
140138 var params = args['params' ] != null
141139 ? (args['params' ] as Map <String , dynamic >)
142140 : < String , dynamic > {};
143- var response =
144- await appState.vmService .callServiceExtension (methodName, args: params);
141+ var response = await appState.vmService !
142+ .callServiceExtension (methodName, args: params);
145143 return response.json;
146144 }
147145
@@ -168,7 +166,7 @@ class AppDomain extends Domain {
168166 'message' : 'Performing hot restart...' ,
169167 'progressId' : 'hot.restart' ,
170168 });
171- var response = await appState.vmService.callServiceExtension ('hotRestart' );
169+ var response = await appState.vmService! .callServiceExtension ('hotRestart' );
172170 sendEvent ('app.progress' , {
173171 'appId' : appId,
174172 'id' : '$_progressEventId ' ,
@@ -193,7 +191,7 @@ class AppDomain extends Domain {
193191 }
194192 // Note that this triggers the daemon to shutdown as we listen for the
195193 // tabConnection to close to initiate a shutdown.
196- await appState._debugConnection? .close ();
194+ await appState._debugConnection.close ();
197195 // Wait for the daemon to gracefully shutdown before sending success.
198196 await daemon.onExit;
199197 return true ;
@@ -216,15 +214,15 @@ class _AppState {
216214
217215 bool _isDisposed = false ;
218216
219- VmService get vmService => _debugConnection? .vmService;
217+ VmService ? get vmService => _debugConnection.vmService;
220218
221219 _AppState (this ._debugConnection, this ._resultSub, this ._stdOutSub);
222220
223221 void dispose () {
224222 if (_isDisposed) return ;
225223 _isDisposed = true ;
226- _stdOutSub? .cancel ();
227- _resultSub? .cancel ();
228- _debugConnection? .close ();
224+ _stdOutSub.cancel ();
225+ _resultSub.cancel ();
226+ _debugConnection.close ();
229227 }
230228}
0 commit comments