mainIsolateRootLibraryUriAsString method

Future<String?> mainIsolateRootLibraryUriAsString()

Returns a file URI String for the root library of the connected app's main isolate.

If a non-null value is returned, the value will be a file URI String and it will NOT have a trailing slash.

Implementation

Future<String?> mainIsolateRootLibraryUriAsString() async {
  final mainIsolateState = await isolateManager.waitForMainIsolateState();
  if (mainIsolateState == null) return null;

  final rootLib = mainIsolateState.rootInfo?.library;
  if (rootLib == null) return null;

  final selectedIsolateRefId = isolateManager.mainIsolate.value!.id!;
  await resolvedUriManager.fetchFileUris(selectedIsolateRefId, [rootLib]);
  final fileUriString = resolvedUriManager.lookupFileUri(
    selectedIsolateRefId,
    rootLib,
  );
  _log.fine('rootLibraryForMainIsolate: $fileUriString');
  return fileUriString;
}