diff --git a/dev/bots/test.dart b/dev/bots/test.dart index d163dd8707..08c94cc734 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -598,6 +598,12 @@ Future _runBuildTests() async { path.join('dev', 'integration_tests', 'web_compile_tests'), path.join('lib', 'dart_io_import.dart'), ), + // Should be able to compile with a call to: + // BackgroundIsolateBinaryMessenger.ensureInitialized. + () => _flutterBuildDart2js( + path.join('dev', 'integration_tests', 'web_compile_tests'), + path.join('lib', 'background_isolate_binary_messenger.dart'), + ), ], runForbiddenFromReleaseTests, ]..shuffle(math.Random(0)); diff --git a/dev/integration_tests/web_compile_tests/lib/background_isolate_binary_messenger.dart b/dev/integration_tests/web_compile_tests/lib/background_isolate_binary_messenger.dart new file mode 100644 index 0000000000..98d823c694 --- /dev/null +++ b/dev/integration_tests/web_compile_tests/lib/background_isolate_binary_messenger.dart @@ -0,0 +1,12 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui' as ui; +import 'package:flutter/services.dart'; + +void main() { + BackgroundIsolateBinaryMessenger.ensureInitialized( + ui.RootIsolateToken.instance! + ); +} diff --git a/packages/flutter/lib/src/services/_background_isolate_binary_messenger_web.dart b/packages/flutter/lib/src/services/_background_isolate_binary_messenger_web.dart index e9079c6f4d..04ae5df5b1 100644 --- a/packages/flutter/lib/src/services/_background_isolate_binary_messenger_web.dart +++ b/packages/flutter/lib/src/services/_background_isolate_binary_messenger_web.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:ui' as ui show RootIsolateToken; import 'binding.dart'; /// Stand-in for non-web platforms' [BackgroundIsolateBinaryMessenger]. @@ -10,4 +11,9 @@ class BackgroundIsolateBinaryMessenger { static BinaryMessenger get instance { throw UnsupportedError('Isolates not supported on web.'); } + + /// Throws an [UnsupportedError]. + static void ensureInitialized(ui.RootIsolateToken token) { + throw UnsupportedError('Isolates not supported on web.'); + } }