normalizePath method

String normalizePath(
  1. String filePath
)

Normalizes filePath to avoid issues with different casing of drive letters on Windows.

Some clients like VS Code do their own normalization and may provide drive letters case different in some requests (such as breakpoints) to drive letters computed elsewhere (such in Platform.resolvedExecutable). When these do not match, breakpoints may not be hit.

This is the case for the whole path, but drive letters are most commonly mismatched due to VS Code's explicit normalization.

https://github.com/dart-lang/sdk/issues/32222

Implementation

String normalizePath(String filePath) {
  if (!Platform.isWindows || filePath.isEmpty || path.isRelative(filePath)) {
    return filePath;
  }
  return filePath.substring(0, 1).toUpperCase() + filePath.substring(1);
}