list method

  1. @override
Future<List<GitFileSystemEntry>> list(
  1. String path
)
override

Lists the direct children of the directory at path, sorted by name.

Throws when path is absent or names a file.

Implementation

@override
Future<List<GitFileSystemEntry>> list(String path) async {
  final String normalized = _resolve(path);
  if (!_directories.contains(normalized)) {
    throw StateError('no directory at "$path"');
  }
  final List<GitFileSystemEntry> entries = <GitFileSystemEntry>[
    for (final String child in _childrenOf(normalized))
      GitFileSystemEntry(
        name: _baseName(child),
        isDirectory: _directories.contains(child),
      ),
  ];
  entries.sort(
    (GitFileSystemEntry first, GitFileSystemEntry second) =>
        first.name.compareTo(second.name),
  );
  return entries;
}