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
26
votes
5 answers

Flutter Isolate vs Future

I might have the wrong idea of Isolate and Future. Please help me to clear it up. Here is my understanding of both subjects. Isolate: Isolates run code in its own event loop, and each event may run smaller tasks in a nested microtask queue. Future:…
Panda World
  • 1,704
  • 1
  • 20
  • 28
21
votes
3 answers

Dart: handle incoming HTTP requests in parallel

I am trying to write an HTTP server in Dart that can handle multiple requests in parallel. I have been unsuccessful at achieving the "parallel" part thus far. Here is what I tried at first: import 'dart:io'; main() { …
Michael Hixson
  • 1,250
  • 1
  • 10
  • 15
21
votes
3 answers

Will Dart execute isolates in parallel in a multi-core environment?

Question Will isolates in Dart run in parallel utilizing all available cores on a multiple core environment, or will it multiplex on a single core? Background Google has described isolates (a single-threaded unit of concurrency) in the Dart…
Xyz
  • 5,955
  • 5
  • 40
  • 58
12
votes
1 answer

Dart Error: Dart_LookupLibrary: library 'package:background_fetch/background_fetch.dart' not found

How can I solve this problem: E/flutter (18287): [ERROR:flutter/shell/common/shell.cc(89)] Dart Error: Dart_LookupLibrary: library 'package:background_fetch/background_fetch.dart' not found. E/flutter (18287):…
Maalmi
  • 123
  • 5
12
votes
2 answers

Multiple Isolates vs one Isolate

How isolates are distributed across CPU cores In Dart, you can run multiple isolates at the same time, and I haven't been able to find a guideline or best practice for using isolates. My question is how will overall CPU usage and performance be…
Mohammed Alfateh
  • 3,186
  • 1
  • 10
  • 24
12
votes
1 answer

What thread / isolate does flutter run IO operations on?

In flutter when using the http package or doing general IO operations for example import 'package:http/http.dart' as http; http.Response response = await http.get(url); if (response.statusCode == 200) { var json = jsonDecode(response.body);…
ams
  • 60,316
  • 68
  • 200
  • 288
12
votes
2 answers

Bidirectional communication with isolates in Dart 2

I'm trying isolates and I'm wondering how could I spawn some of them doing heavy computations that, when the root Isolate ask them for their current computing value they respond it, "on demand". As far as I know, the only object that can be used as…
Nico Rodsevich
  • 2,393
  • 2
  • 22
  • 32
11
votes
1 answer

"threads" in Dart using Flutter for web

I'm currently implementing a simulation for some mathematical problems. Since Flutter has such an easy way to create user interfaces and has web-support, I decided to use Flutter for this project. So far, everything works perfectly. The problem…
Alb
  • 1,063
  • 9
  • 33
11
votes
1 answer

Flutter - How do I compute a heavy task that includes a future without blocking the UI?

I'm creating an app that fetches posts from the internet as json. I parse the json into Post objects in flutter using a factory. A Post object includes a title, body and image. I display these posts in a listview with a listview builder. The heavy…
Gromdroid
  • 483
  • 1
  • 7
  • 15
11
votes
1 answer

How can I dynamically construct a Dart script for spawnUri?

I want to dynamically construct and load a Dart script. How do I do this? I know I can use Isolate.spawnUri to dynamically load a Dart script. However, I'm only aware that I can load from file: and http: URIs. This means I need to put my script…
Seth Ladd
  • 112,095
  • 66
  • 196
  • 279
10
votes
2 answers

How to pass arguments (besides SendPort) to a spawned isolate in Dart

In this article, they spawned an isolate like this: import 'dart:isolate'; void main() async { final receivePort = ReceivePort(); final isolate = await Isolate.spawn( downloadAndCompressTheInternet, receivePort.sendPort, ); …
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
10
votes
3 answers

is flutter (dart) able to make an api request in separate isolate?

I made a function to post notification to a topic. It works great in normally, then I put it in compute function and hope it can posts notification in the background. But it not works. Here is my code: void onSendMessageInBackGround(String message)…
Khánh Vũ Đỗ
  • 895
  • 1
  • 7
  • 13
8
votes
1 answer

How to do several asynchronous I/O actions in Dart cleanly (Isolates)?

In Dart, there is a concept of Isolates. I have an application (that I'm experimenting in Dart) that has lots of asynchronous IO where each call (they are database calls) are dependent on the previous one. So I have ended up in a nested callback…
Tower
  • 98,741
  • 129
  • 357
  • 507
8
votes
3 answers

Flutter: avoid UI freeze when massive Database operation is in progress

UPDATE (15 july 2020) mFeinstein's response, for now, is the only answer which gives me the first acceptable solution. QUESTION I have to ask you what is the best approach for doing what i'm trying to do: Calling a web service in async…
kinghomer
  • 3,021
  • 2
  • 33
  • 56
8
votes
2 answers

In Flutter, how do we use Firebase Messaging onBackgroundMessage to create a notification, using flutter_local_notifications?

We are working on an encrypted chat application where we use Firebase Messaging for data notifications. Some client-side logic needs to be done upon receiving a data notification, before showing an actual notification to the user. For example, a…
1
2 3
19 20