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
8
votes
1 answer

How to pass message to isolate and handle error

I am trying to use dart isolate library to improve my application performance. Look at following code: import 'dart:isolate'; import 'package:dbcrypt/dbcrypt.dart'; main() { var pwConPort = new ReceivePort(); pwConPort.listen((data) { …
softshipper
  • 32,463
  • 51
  • 192
  • 400
8
votes
1 answer

Is it safe to use global variable to share objects between functions in Dart?

I see that "Dart is a single-threaded programming language", so I think is it safe to use global variable to pass data between functions: var g = 1; main() { hello(); world(); } def hello() { g = 2; } def world() { print(g); } I…
Freewind
  • 193,756
  • 157
  • 432
  • 708
7
votes
3 answers

Unhandled Exception: Invalid argument(s): Illegal argument in isolate message: (object extends NativeWrapper - Library:'dart:ui' Class: Path)

Can anyone tell me whats wrong in this code? void onPressed() async { //Navigator.pushNamed(context, "/screen2", arguments: []); var receivePort = ReceivePort(); await Isolate.spawn(gotoNext, [receivePort.sendPort]); final msg =…
Varun Verma
  • 73
  • 1
  • 1
  • 4
7
votes
1 answer

Cannot execute Firebase Query within Isolate

I'm developping an app using Flutter. And I want to execute some Firebase queries using Isolate. But each time I run the app I get this error and nothing is displayed. Here my code class HomePage extends StatefulWidget { HomePage({Key key,…
FQDEV
  • 173
  • 3
  • 13
7
votes
1 answer

Can I pass a BuildContext to Compute?

Is it possible to use BuildContext inside compute function? Future getFuture() async { int r = await compute(count, context); return r; } static int count(BuildContext context) { // Something very slow. return 10; } I receive the…
user987654
  • 5,461
  • 5
  • 23
  • 26
7
votes
1 answer

Call async function from Isolate function

I am trying to call an async function from the Isolate function. class IsolateExample { final ReceivePort port = new ReceivePort(); IsolateExample(){ Isolate.spawn(isolateFunction, port.sendPort); } static isolateFunction(SendPort…
Anil8753
  • 2,663
  • 4
  • 29
  • 40
7
votes
2 answers

How to terminate a long running isolate #2

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

How do I fix this Sentry Zone mismatch error?

Framework / SDK versions: Flutter: 3.10.4 Dart: 3.0.3 Here goes my main() code: Future main() async { //debugPaintSizeEnabled = true; //BindingBase.debugZoneErrorsAreFatal = true; WidgetsFlutterBinding.ensureInitialized(); …
Void
  • 1,129
  • 1
  • 8
  • 21
6
votes
1 answer

Is there currently a way to compute a dart function with webworkers?

I am currently trying to run a A* seek computation on flutter web class AStarSeeker extends Seeker { @override Future Function() seek(SeekComputationInput input) { return () => compute(doComputation, input); } } Future
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
6
votes
0 answers

Dart isolate is very slow when running a function that returns a very long list

In my Flutter project for Windows, I use the compute function to run some code in an Isolate, in order to avoid freezing the user interface. But I'm facing a problem: the code I run in the Isolate returns a very long list of double (a few millions…
matteoh
  • 2,810
  • 2
  • 29
  • 54
6
votes
1 answer

Shared Preference in flutter Isolate

I'm new to flutter and I just learned how to use isolates in Dart. When I try to access shared preference via an isolate it throws the given below error. This error also appears when I try to access Firebase analytics and remote config. How can I…
Nishuthan S
  • 1,538
  • 3
  • 12
  • 30
6
votes
0 answers

Flutter Uploading a video through DIO package on Isolate

I'm trying to upload a video on my AWS S3 server using dio package. What is happening: video's are uploading successfully but the api call blocks the UI thread and it will really slow down the app during upload. All other api calls through dio are…
Minhaj Javed
  • 913
  • 8
  • 20
6
votes
1 answer

Is it possible to get the instance of an existing Isolate in Flutter after reopening the App?

I am using dart isolates to play music in background. I want to get the instance of the isolate that I spawned earlier to stop the music after closing and re-opening the Flutter App. Is there a way to get the instance of existing isolates after…
Power Coding
  • 71
  • 1
  • 3
6
votes
1 answer

Dart Isolates accessing a shared object instance

I'm currently working with isolates to send queries in parallel to a database server. I have a connector-object to build the connection to the database and I would like to share that across all isolates, so I don't have to create a separate…
torpedro
  • 494
  • 5
  • 13
6
votes
2 answers

Dart Isolate vs Akka

From what I have understood, Dart isolate is like Akka actors. However, what I couldn't figure out is if dart:isolate serves similar purpose as Akka does. Is there a fundamental difference between the two ? Is dart:isolate a framework for actor…
lihsus
  • 297
  • 3
  • 12
1
2
3
19 20