Unverified Commit 97866824 authored by David Iglesias's avatar David Iglesias Committed by GitHub

[web] Add BackgroundIsolateBinaryMessenger.ensureInitialized to web. (#145786)

This PR makes the static API of the `BackgroundIsolateBinaryMessenger` consistent between its web and IO implementations.

This way, multi-platform applications will compile for the web when using the `ensureInitialized` method (even though it'll throw at runtime, like the `instance` getter, because isolates are not supported on the web).

### Issues

* Fixes: https://github.com/flutter/flutter/issues/145260
parent d2a19380
......@@ -598,6 +598,12 @@ Future<void> _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));
......
// 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!
);
}
......@@ -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.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment