Isolate.spawn(). Is it possible to pass a class by reference to an isolate? I did read that it is possible, but I could find no example. Even though the Isolate has it’s own memory space, I don’t see why it should not be possible to pass by reference. What I want to do is pass a class by reference to the isolate and for the isolate to update a member of that class and then return a response with the data being in the Class. It appears however from my testing that the Isolate simply copies the class and then updates its copy with the return value. Obviously if this were possible (by reference) it would be more efficient for large data items. If possible, an example would be good. If not possible, some information as to the reason would be helpful.
In Flutter is it possible to pass a Class by reference to an Isolate?
35 views Asked by Brian Oh At
1
There are 1 answers
Related Questions in FLUTTER
- Flutter + Dart: Editing name of a tab shows up a black screen
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- Way to get CustomPainter to track face in Camera Flutter MLKit
- flutter Null check error: did not show file and line number
- Creating multiple instances of a class with different initializing values in Flutter
- I want to paste stickers into to my TextField and to show the stickers beside the emojis
- Flutter plugin development android src not opening after opening example
- Module not found when building flutter app for IOS
- How to make barrier area interactive in flutter modal bottom sheet
- Can an RPC result be included in a Supabase select function in Flutter for Data Modeling?
- Why do I need to wait to reaccess to Firestore database even though it has already done before?
- Flutter web app on Windows -how to support mouse drag for horizontal and vertical scrolling as well as using mouse wheel
- I wrote this time displaying FLUTTER app, How can I improve it?
- Appwrite and / or Spring Boot Backend
- Flutter two_dimensional_scrollables Web app Chrome - cannot get horizontal scroll to work?
Related Questions in DART-ISOLATES
- Flutter - invoking method in method channel from a different isolate
- In Flutter is it possible to pass a Class by reference to an Isolate?
- spawanUri in flutter error with[ERROR:flutter/runtime/dart_isolate.cc(935)] CreateDartIsolateGroup failed: Could not prepare the child isolate to run
- Flutter isolate bad performance with big list
- In Flutter, How we can pass information to another isolate, so that other isolates know the widgets have been initialized in the main thread?
- Does dart code of a different `@pragma(vm:entry-point)` runs in a separate isolate?
- Flutter Isolate.run with multiple arguments
- Background isolate platform channel difference between internal and external plugins
- Failing to send a serialized freezed object over a port to another isolate
- Invoking Dart Callbacks from Zenoh C Threads - Isolate and Callback Error
- how to use isolate for pick file?
- in flutter i have build a dart isolate but it is not uploading files to server dart isolate not working perfectly in the flutter
- Workmanager starts itself again when app is killed in flutter
- Flutter child isolate can not dependent on flutter engine(WidgetsFlutterBinding.ensureInitialized())
- Flutter Isolate Null check operator used on a null value error in compute and spawn functions
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
What prompted this question is the problem that I have whereby I am creating about 10 Bar-Charts using Widgets as opposed to painting them. It takes roughly 2.5 seconds to create and then display the Bar-Charts on a not-too-fast Android phone. I previously created Pie Charts for the same data and that is much faster. So, I wanted to display a CircularProgressIndicator or similar while the Bar-Charts are being constructed. Surprisingly to me, there does not appear to be an easy way to do this. This led me to investigate the use of isolates. I have used Isolates previously for the download of a large number of items from the net using multiple Isolates. This worked quite well. This case however, it appears much more complex to achieve with Isolates. One factor being that an Isolate cannot call an external Function. Isolates have a very restrictive model by design, apparently to keep them relatively simple compared to the alternative. So, I will attempt to find another alternative to solve my problem – just so that I can display a CircularProgressIndicator. Perhaps it is possible to do that using a Timer.
From the Isolate documentation: “Dart’s isolates are an implementation of the Actor model. They can only communicate with each other by message passing, which is done with Port objects. When messages are “passed” between each other, they are generally copied from the sending isolate to the receiving isolate. This means that any value passed to an isolate, even if mutated on that isolate, doesn’t change the value on the original isolate.”
“The only objects that aren’t copied when passed to an isolate are immutable objects that can’t be changed anyway, such a String or an unmodifiable byte. When you pass an immutable object between isolates, a reference to that object is sent across the port, rather than the object being copied, for better performance. Because immutable objects can’t be updated, this effectively retains the actor model behavior.”
UPDATE:
I did implement the Timer and the CircularProgressIndicator which although it did work as it should, it did not solve the problem because the time was not spent building the widgets, but displaying them, by which time the updates to the CircularProgressIndicator had completed. I solved this by adding the Bar-Charts one-by one and after adding each one updating the State of the Widget that displays them. Now there is no noticeable delay. So, an Isolate was not the solution (too complex or impossible or would not have solved the problem) and a Timer was not the solution even though it worked as intended, because the delay was in the display of the Widget or so it seems.