diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index 6ab7b053d2..33846d217e 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -94,7 +94,7 @@ Future main(List args) async { AppContext _executableContext = new AppContext(); // Make the context current. - _executableContext.runInZone(() { + await _executableContext.runInZone(() { // Initialize the context with some defaults. // NOTE: Similar lists also exist in `bin/fuchsia_builder.dart` and // `test/src/context.dart`. If you update this list of defaults, look diff --git a/packages/flutter_tools/lib/src/base/context.dart b/packages/flutter_tools/lib/src/base/context.dart index 96768a43a5..bb28b6e84a 100644 --- a/packages/flutter_tools/lib/src/base/context.dart +++ b/packages/flutter_tools/lib/src/base/context.dart @@ -59,7 +59,7 @@ class AppContext { : parentContext; } - dynamic runInZone(dynamic method(), { + Future runInZone(dynamic method(), { ZoneBinaryCallback onError }) { return runZoned( @@ -69,7 +69,7 @@ class AppContext { ); } - dynamic _run(dynamic method()) async { + Future _run(dynamic method()) async { Zone previousZone = _zone; try { _zone = Zone.current; diff --git a/packages/flutter_tools/test/context_test.dart b/packages/flutter_tools/test/context_test.dart index 841105853f..a589528036 100644 --- a/packages/flutter_tools/test/context_test.dart +++ b/packages/flutter_tools/test/context_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_tools/src/globals.dart'; import 'package:test/test.dart'; void main() { - group('DeviceManager', () { + group('AppContext', () { test('error', () async { AppContext context = new AppContext(); BufferLogger mockLogger = new BufferLogger(); @@ -50,5 +50,31 @@ void main() { expect(mockLogger.statusText, ''); expect(mockLogger.traceText, 'foo bar\n'); }); + + test('awaitNestedZones', () async { + AppContext outerContext = new AppContext(); + await outerContext.runInZone(() async { + AppContext middleContext = new AppContext(); + await middleContext.runInZone(() async { + AppContext innerContext = new AppContext(); + await innerContext.runInZone(() async { + expect(innerContext.getVariable(String), isNull); + }); + }); + }); + }); + + test('fireAndForgetNestedZones', () async { + AppContext outerContext = new AppContext(); + outerContext.runInZone(() async { + AppContext middleContext = new AppContext(); + middleContext.runInZone(() async { + AppContext innerContext = new AppContext(); + innerContext.runInZone(() async { + expect(innerContext.getVariable(String), isNull); + }); + }); + }); + }); }); }