replaceAsExpected static method

String replaceAsExpected({
  1. required String path,
  2. String? replaceChar,
})

Implementation

static String replaceAsExpected({required String path, String? replaceChar}) {
  if (path.contains('\\')) {
    if (Platform.isLinux || Platform.isMacOS) {
      return path.replaceAll('\\', '/');
    } else {
      return path;
    }
  } else if (path.contains('/')) {
    if (Platform.isWindows) {
      return path.replaceAll('/', '\\\\');
    } else {
      return path;
    }
  } else {
    return path;
  }
}