Questions tagged [dart-isolates]

In the Dart programming language, an Isolate is a single-threaded unit of concurrency.

In the Dart programming language, an Isolate is a single-threaded unit of concurrency. Communication with others Isolates is done via message passing.

Introduktion to Dart Isolate

dart:isolate library

296 questions
3
votes
1 answer

need Dart mirror instantiate() function

to add some sanity to my life, looking for instantiate() function as syntactic sugar to Dart's mirror library: instantiate( class|type|instance, argArray ) class Klass { int i1; Klass( int i1 ) { this.i1 = (i1 is int) ? i1 : 0; } } type…
cc young
  • 18,939
  • 31
  • 90
  • 148
3
votes
1 answer

How do you use the Isolate.spawnUri method to control an isolate?

I'm looking through the documentation for Isolates and noticed that you can use the static method spawnUri to create an isolate from a file. As seen here: http://api.dartlang.org/docs/releases/latest/dart_isolate/Isolate.html#spawnUri On that…
Tom C
  • 822
  • 7
  • 27
3
votes
2 answers

SpawnDomUri: Restrict to specific Dom-Node

I want to start some Isolate, which manipulates a specific area in my webpage. To achieve this, I create such an Isolate via the function SpawnDomUri, which is able to access the DomTree. Apparently, some malicious/erroneous Isolate may change the…
Alex R.
  • 205
  • 1
  • 10
3
votes
3 answers

How to terminate a long running isolate

I am trying to understand how I shall port my Java chess engine to dart. So I have understood that I should use Isolates and/or Futures to run my engine in parallell with the GUI but how can I force the engine to terminate the search. In java I just…
Gunnar Eketrapp
  • 2,009
  • 1
  • 19
  • 33
3
votes
1 answer

Dart - Isolate Cross Window Communication

Is cross-window communication possible with Dart isolates? Here is my scenario: User opens web site in browser window A and window A spawns a new isolate. The user then clicks a link that creates a new tab and opens browser window B (assume the…
2
votes
0 answers

Flutter - IsolateNameServer.lookupPortByName('port_name') is null

I am a beginner in Flutter. I am working on a Geofencing feature. Whenever a user enters/exits the geofence region, a local notification should get fired. Here is the code I am using ReceivePort port =…
Yakshita
  • 21
  • 2
2
votes
0 answers

Bad state: The BackgroundIsolateBinaryMessenger.instance value is invalid until BackgroundIsolateBinaryMessenger.ensureInitialized is executed

static getMaxId(SendPort sendPort) async { ApiService apiService = ApiService(); var maxId = await apiService.getMId("1"); sendPort.send(getFeedData(maxId)); } static getFeedData(dynamic maxId) async { ApiService apiService =…
Tintin V
  • 23
  • 4
2
votes
0 answers

How to start a process on main isolate from background task

In a Flutter app, a background task can be started via a local notification (e.g. onDidReceiveBackgroundNotificationResponse from flutter_local_notifications plugin). The main isolate may or may not be active at this point and as far as my…
2
votes
2 answers

dart Isolate listen don't triggered (or work)

My class: import 'dart:isolate'; import 'dart:ui'; import 'package:flutter_downloader/flutter_downloader.dart'; class SettingsPage extends StatefulWidget with WidgetsBindingObserver { SettingsPage({Key? key}) : super(key: key); @override …
2
votes
1 answer

Dart event loop: understanding why such order print (Case 4)

There is the following code: Case 1. Basic Example Future main() async { print('A'); await Future( () { print('C'); Future(() => print('D')); Future(() => print('E')).then((value) => print('F')); …
2
votes
2 answers

Correctly killing newly spawned isolates

I am aware of the fact that when both microtask and event queues of an isolate are empty, the isolate is killed. However, I'm not able to find a reference on the documentation of how a worker isolate can be killed under certain…
Alberto Miola
  • 4,643
  • 8
  • 35
  • 49
2
votes
0 answers

Precaching network responses using `Isolates` with Dio and Hive

I just want to precache some endpoint calls at the beginning of the app to load faster some request since the backend service is really slow. I've tried using Isolates for this but seems like Hive Cache doesn't support that, so even if I try to…
Keylin Wu
  • 33
  • 7
2
votes
0 answers

Dart isolate group implementation

I'm trying to understand how memory and processes like garbage collection are implemented in isolate groups in Dart. The article Introduction to Dart VM at the time of this writing includes the following image: However, this image was made prior to…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
2
votes
1 answer

How to break up Dart Isolate code to avoid blocking the event queue?

I am writing a test program to explore the use of Isolates in Dart/Flutter. One type of isolate that I have is started and stopped using a switch on a Flutter UI. This sends a message (START and STOP) to the isolate and I use a ValueNotifier to…
Twelve1110
  • 175
  • 12
2
votes
0 answers

Flutter: MissingPluginException when I call platform channel from spawned isolate using isolate_handler package

When I want to call a method channel from a spawned isolate using isolate_handler (because it doesn't work using dart's isolates), I get a MissingPluginException which doesn't happen when calling method channel from the main isolate. class…