sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Isolate group callbacks can capture mutable `late final` variables.

Open alexmarkov opened this issue 6 days ago • 7 comments

Example:


import 'dart:ffi';

void main(List<String> args) {
  late final List<String> list;
  final callback = NativeCallable<Void Function()>.isolateGroupBound(() {
    list.add('hey');
  });
  list = [];
  callback.nativeFunction.asFunction<void Function()>().call();
  print(list);
  callback.close();
}

late final variables can be initialized later, after isolate group callback is created, so they are somewhat mutable. This would bypass check that values of captured variables are shareable and would allow sharing arbitrary mutable Dart objects between isolate group callback and Dart isolate.

/cc @aam

alexmarkov avatar Dec 05 '25 20:12 alexmarkov