Home > Enterprise >  How is Dart Isolate implemented in Flutter for Android/ iOS?
How is Dart Isolate implemented in Flutter for Android/ iOS?

Time:12-07

I have a problem understanding Dart Isolates and how they are implemented in Flutter for Android/ iOS. This answer states that "Dart is compiled to native machine code (ARM, Intel, ...) executable and bundled with some native platform code (Java, Kotlin, Objective-C/Swift) to interact with the native platform."

When I use a Dart Isolate in Flutter, e.g. for Android, is the Isolate compiled to something like Workmanager, or does it "only" use the Dart Isolate itself?

CodePudding user response:

When you use a Dart isolate in Flutter, the Dart code is compiled to native machine code that runs on the device's processor. This code is then bundled with platform-specific native code (such as Java or Kotlin on Android, or Objective-C or Swift on iOS) to allow the Dart code to interact with the native platform.

Flutter itself does not use the Android WorkManager or any other specific platform-specific APIs for isolates. Instead, Flutter uses its own Dart-based isolate implementation to run Dart code in a separate, independent thread. This allows Dart code to run concurrently with the main UI thread, which can improve performance and responsiveness in your Flutter app.

You can learn more about how isolates work in Dart and Flutter in the Dart documentation: https://dart.dev/guides/language/language-tour#isolates

CodePudding user response:

Flutter is a high level implementation of things, you don't need to think on processor level, system process level it is all handled by Target OS,

On low level a Thread is a light-weight process that performs some task and uses system resources like CPU,

As per ISOLATE specification

Each Dart isolate has a single thread of execution and shares no mutable objects with other isolates.

Using Isolate you create a separate thread that handles the separate task without intercepting the main thread of your dart/flutter App,

  • Related