sortByDate property

Future<List<FileSystemEntity>> get sortByDate

Implementation

Future<List<FileSystemEntity>> get sortByDate async {
  final List<_PathStat> _pathStat = [];

  for (final entity in this) {
    final stat = await entity.stat();
    _pathStat.add(_PathStat(entity.path, stat.modified));
  }

  _pathStat.sort((a, b) => b.dateTime.compareTo(a.dateTime));

  return _pathStat
      .map((pathStat) =>
          this.firstWhere((entity) => entity.path == pathStat.path))
      .toList();
}