run method

  1. @override
Future<List<String>> run()
override

Method that will be executed in the functionality. Remember when overrided to establish async.

Implementation

@override
Future<List<String>> run() async {
  List<File> historyFiles = [];
  List<String> result = [];

  // Filter by date
  if (this._date != null) {
    historyFiles = await _getFilesByDate();
    if (historyFiles.isEmpty) return [];
    for (File file in historyFiles) result.addAll(file.readAsLinesSync());
    result = _getResultByTime(result);
  } else {
    historyFiles =
        _getAllFilesFromDirectory(Directory(this._historyFolderPath));
    if (historyFiles.isEmpty) return [];
    for (File file in historyFiles) result.addAll(file.readAsLinesSync());
  }

  // Filter by entry
  if (this._entry != null)
    for (int i = result.length - 1; i >= 0; i--)
      if (!result[i].contains(this._entry!)) result.remove(result[i]);

  return result;
}