This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ void UIDartState::DidSetIsolate() {
9797
9898void UIDartState::ThrowIfUIOperationsProhibited () {
9999 if (!UIDartState::Current ()->IsRootIsolate ()) {
100+ Dart_EnterScope ();
100101 Dart_ThrowException (
101102 tonic::ToDart (" UI actions are only available on root isolate." ));
102103 }
Original file line number Diff line number Diff line change 33// found in the LICENSE file.
44
55import 'dart:isolate' ;
6+ import 'dart:ui' ;
67
78import 'package:litetest/litetest.dart' ;
89
@@ -20,4 +21,14 @@ void main() {
2021 }
2122 expect (threw, true );
2223 });
24+
25+ test ('UI isolate API throws in a background isolate' , () async {
26+ void callUiApi (void message) {
27+ PlatformDispatcher .instance.onReportTimings = (_) {};
28+ }
29+ final ReceivePort errorPort = ReceivePort ();
30+ await Isolate .spawn <void >(callUiApi, null , onError: errorPort.sendPort);
31+ final List <dynamic > isolateError = await errorPort.first as List <dynamic >;
32+ expect (isolateError[0 ], 'UI actions are only available on root isolate.' );
33+ });
2334}
You can’t perform that action at this time.
0 commit comments