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-
75@JS ()
86library require_reloading_manager;
97
@@ -23,7 +21,8 @@ import 'restarter.dart';
2321/// The last known digests of all the modules in the application.
2422///
2523/// This is updated in place during calls to hotRestart.
26- Map <String , String > _lastKnownDigests;
24+ /// TODO(annagrin): can this be a private field in RequireRestarter?
25+ late Map <String , String > _lastKnownDigests;
2726
2827@JS (r'$requireLoader' )
2928external RequireLoader get requireLoader;
@@ -90,8 +89,8 @@ abstract class JsMap<K, V> {
9089/// Handles hot restart reloading for use with the require module system.
9190class RequireRestarter implements Restarter {
9291 final _moduleOrdering = HashMap <String , int >();
93- SplayTreeSet <String > _dirtyModules;
94- var _running = Completer <bool >()..complete ();
92+ late SplayTreeSet <String > _dirtyModules;
93+ var _running = Completer <bool >()..complete (true );
9594
9695 var count = 0 ;
9796
@@ -100,7 +99,7 @@ class RequireRestarter implements Restarter {
10099 }
101100
102101 @override
103- Future <bool > restart ({String runId}) async {
102+ Future <bool > restart ({String ? runId}) async {
104103 final developer = getProperty (require ('dart_sdk' ), 'developer' );
105104 if (callMethod (getProperty (developer, '_extensions' ), 'containsKey' ,
106105 ['ext.flutter.disassemble' ]) as bool ) {
@@ -117,7 +116,7 @@ class RequireRestarter implements Restarter {
117116 'Unable to find an existing digest for module: $moduleId .' );
118117 _reloadPage ();
119118 } else if (_lastKnownDigests[moduleId] != newDigests[moduleId]) {
120- _lastKnownDigests[moduleId] = newDigests[moduleId];
119+ _lastKnownDigests[moduleId] = newDigests[moduleId]! ;
121120 modulesToLoad.add (moduleId);
122121 }
123122 }
@@ -145,7 +144,7 @@ class RequireRestarter implements Restarter {
145144 }
146145
147146 List <String > _moduleParents (String module) =>
148- requireLoader.moduleParentsGraph.get (module)? .cast () ?? [] ;
147+ requireLoader.moduleParentsGraph.get (module).cast ();
149148
150149 int _moduleTopologicalCompare (String module1, String module2) {
151150 var topological = 0 ;
@@ -159,8 +158,8 @@ class RequireRestarter implements Restarter {
159158 'Unable to fetch ordering info for module: $missing ' );
160159 }
161160
162- topological =
163- Comparable . compare ( _moduleOrdering[module2], _moduleOrdering[module1]);
161+ topological = Comparable . compare (
162+ _moduleOrdering[module2]! , _moduleOrdering[module1]! );
164163
165164 if (topological == 0 ) {
166165 // If modules are in cycle (same strongly connected component) compare
@@ -183,13 +182,13 @@ class RequireRestarter implements Restarter {
183182 var reloadedModules = 0 ;
184183 try {
185184 _dirtyModules.addAll (modules);
186- String previousModuleId;
185+ String ? previousModuleId;
187186 while (_dirtyModules.isNotEmpty) {
188187 final moduleId = _dirtyModules.first;
189188 _dirtyModules.remove (moduleId);
190189 final parentIds = _moduleParents (moduleId);
191190 // Check if this is the root / bootstrap module.
192- if (parentIds == null || parentIds .isEmpty) {
191+ if (parentIds.isEmpty) {
193192 // The bootstrap module is not reloaded but we need to update the
194193 // $dartRunMain reference to the newly loaded child module.
195194 final childModule = callMethod (
0 commit comments