getMainIsolate method

Future<Isolate?> getMainIsolate()

Implementation

Future<Isolate?> getMainIsolate() async{
  IsolateRef? ref;
  final vm = await getVM();
  if (vm == null) return null;
  vm.isolates?.forEach((isolate) {
    if (isolate.name == 'main') {
      ref = isolate;
    }
  });
  final vms = await getVMService();
  if (ref?.id != null) {
    return vms.getIsolate(ref!.id!);
  }
  return null;
}