getNextId method

int getNextId()

Implementation

int getNextId() {
  var lastIdFile = File('$location/options/last_id');
  if (lastIdFile.existsSync()) {
    var result = int.parse(lastIdFile.readAsStringSync());
    lastIdFile.writeAsStringSync((result + 1).toString());
    return result + 1;
  } else {
    lastIdFile
      ..createSync(recursive: true)
      ..writeAsStringSync('1');
    return 1;
  }
}