updateIsCheckingToday static method

bool updateIsCheckingToday()

Implementation

static bool updateIsCheckingToday() {
  var configFile = getFileConfig();

  try {
    var lines = configFile.readAsLinesSync();
    var lastUpdateIndex = lines
        .indexWhere((element) => element.startsWith('last_update_check:'));

    // If no last update entry, return false
    if (lastUpdateIndex == -1) {
      return false;
    }

    var dateLastUpdate = lines[lastUpdateIndex].split(':').last.trim();
    var now = _formatter.parse(_formatter.format(DateTime.now()));

    return _formatter.parse(dateLastUpdate) == now;
  } catch (e) {
    print('Error reading the config file: $e');
    return false;
  }
}