toFileUri method
Converts a local path or an already-normalized virtual file URI to an LSP file URI. Virtual file URIs are used by browser clients without a local filesystem.
Implementation
String toFileUri(String filePath, {bool directory = false}) {
final parsed = Uri.tryParse(filePath);
if (parsed != null && parsed.scheme == 'file') {
return parsed.toString();
}
return (directory ? Uri.directory(filePath) : Uri.file(filePath))
.toString();
}