sdk
sdk copied to clipboard
Isolate group callbacks can capture mutable `late final` variables.
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