addPrefix function

String addPrefix(
  1. String path
)

Returns the file system path with the prefix added.

Implementation

String addPrefix(String path) {
  String result;
  if (Platform.isWindows) {
    final hasStoragePrefix = path.startsWith(kWindowsStoragePathPrefix);
    final hasNetworkPrefix = path.startsWith(kWindowsNetworkPathPrefix);
    final hasPrefix = hasStoragePrefix || hasNetworkPrefix;
    final prefix = !hasPrefix ? kWindowsStoragePathPrefix : '';
    result = '$prefix${normalize(path.replaceAll('/', '\\'))}';
  } else {
    result = normalize(path);
  }

  return removeTrailingSlash(result);
}