withoutExtension method

String withoutExtension (String path)

Removes a trailing extension from the last part of path.

context.withoutExtension('path/to/foo.dart'); // -> 'path/to/foo'

Implementation

String withoutExtension(String path) {
  var parsed = _parse(path);

  for (var i = parsed.parts.length - 1; i >= 0; i--) {
    if (!parsed.parts[i].isEmpty) {
      parsed.parts[i] = parsed.basenameWithoutExtension;
      break;
    }
  }

  return parsed.toString();
}