@@ -15,7 +15,6 @@ import 'package:provider/provider.dart';
15
15
import 'package:split_view/split_view.dart' ;
16
16
import 'package:url_launcher/url_launcher.dart' as url_launcher;
17
17
import 'package:vtable/vtable.dart' ;
18
- import 'package:web/web.dart' as web;
19
18
20
19
import 'console.dart' ;
21
20
import 'docs.dart' ;
@@ -24,6 +23,7 @@ import 'embed.dart';
24
23
import 'execution/execution.dart' ;
25
24
import 'extensions.dart' ;
26
25
import 'keys.dart' as keys;
26
+ import 'local_storage.dart' ;
27
27
import 'model.dart' ;
28
28
import 'problems.dart' ;
29
29
import 'samples.g.dart' ;
@@ -273,25 +273,27 @@ class _DartPadMainPageState extends State<DartPadMainPage>
273
273
);
274
274
275
275
appServices.populateVersions ();
276
- appServices
277
- .performInitialLoad (
278
- gistId: widget.gistId,
279
- sampleId: widget.builtinSampleId,
280
- flutterSampleId: widget.flutterSampleId,
281
- channel: widget.initialChannel,
282
- fallbackSnippet: web.window.localStorage.getItem ('user_input' ) ??
283
- Samples .defaultSnippet ())
284
- .then ((value) {
285
- // Start listening for inject code messages.
286
- handleEmbedMessage (appServices, runOnInject: widget.runOnLoad);
287
- if (widget.runOnLoad) {
288
- appServices.performCompileAndRun ();
289
- }
290
- });
276
+ _initAppServices ();
291
277
292
278
appModel.compilingBusy.addListener (_handleRunStarted);
293
279
}
294
280
281
+ Future <void > _initAppServices () async {
282
+ await appServices.performInitialLoad (
283
+ gistId: widget.gistId,
284
+ sampleId: widget.builtinSampleId,
285
+ flutterSampleId: widget.flutterSampleId,
286
+ channel: widget.initialChannel,
287
+ fallbackSnippet:
288
+ LocalStorage .instance.getUserCode () ?? Samples .defaultSnippet (),
289
+ );
290
+ // Start listening for inject code messages.
291
+ handleEmbedMessage (appServices, runOnInject: widget.runOnLoad);
292
+ if (widget.runOnLoad) {
293
+ appServices.performCompileAndRun ();
294
+ }
295
+ }
296
+
295
297
@override
296
298
void dispose () {
297
299
appModel.compilingBusy.removeListener (_handleRunStarted);
0 commit comments