getName method

String getName({
  1. Context? pathContext,
})

Gets the part of path after the last separator.

File('path/to/foo.dart').getName(); // -> 'foo.dart'
Directory('path/to').getName();          // -> 'to'

Trailing separators are ignored.

Directory('path/to/').getName(); // -> 'to'

Implementation

String getName({
  lib_path.Context? pathContext,
}) {
  pathContext ??= lib_path.context;
  return pathContext.basename(path);
}