Skip to content

An example of using isolate_agents in a Flutter project using a Romeo and Juliet dialog.

License

Notifications You must be signed in to change notification settings

gaaclarke/romeo_juliet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

romeo_juliet

A demonstration of using isolate_agents to offload work from the ui thread in Flutter.

Getting Started

Generate the platform files by running flutter create . then execute the example with flutter run. All platforms are supported except web since it lacks isolates.

Explanation

The steps that the app takes are the following:

  1. Load the text asset with all the decrypted messages, split them up, encrypt them and write them to the documents directory.
  2. Query the platforms documents directory and store it on the agent.
  3. Start a timer that will trigger a job that will read the encrypted message from the documents directory and decrypt it every second.
  4. When the job is finished, if we have a new decrypted message add it to the cache on the root isolate and reload the scroll view.

How does this code differ from using Isolate directly?

  1. There is much less code and a consistent interface to working with Isolates.

How does this code differ from using Flutter's compute function?

  1. The Isolate lives long enough to be reused whenever we receive the request to decrypt a new message.
  2. The Isolate can store state, in this case the documents directory, so it doesn't have to recalculate it on the Isolate or send it over every time.

About

An example of using isolate_agents in a Flutter project using a Romeo and Juliet dialog.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages