workspaceRoots method
Returns the workspace roots for the Dart Tooling Daemon connection.
These roots are set by the tool that started DTD, which may be the IDE, DevTools server, or DDS (the Dart Development Service managed by the Dart or Flutter CLI tools).
A workspace root is considered any directory that is at the root of the IDE's open project or workspace, or in the case where the Dart Tooling Daemon was started from the DevTools server or DDS (e.g. an app ran from the CLI), a workspace root is the root directory for the Dart or Flutter program connected to DevTools.
By default, the cached value _workspaceRoots
will be returned when
available. When forceRefresh
is true, the cached value will be cleared
and recomputed.
Implementation
Future<IDEWorkspaceRoots?> workspaceRoots({bool forceRefresh = false}) async {
if (!hasConnection) return null;
if (_workspaceRoots != null && forceRefresh) {
_workspaceRoots = null;
}
try {
return _workspaceRoots ??= await _dtd.getIDEWorkspaceRoots();
} catch (e) {
_log.fine('Error fetching IDE workspaceRoots: $e');
return null;
}
}