load method

Future<List<Object?>?> load()

Loads the simple objects from the file. If the file doesn't exist, returns null. If the file exists and is empty, returns an empty list.

Implementation

Future<List<Object?>?> load() async {
  _checkIfFileSystemIsTheSame();
  File file = _file ?? await this.file();

  if (!file.existsSync())
    return null;
  else {
    Uint8List encoded;
    try {
      encoded = await file.readAsBytes();
    } catch (error) {
      if ((error is FileSystemException) && //
          error.message.contains("No such file or directory")) return null;
      rethrow;
    }

    List<Object?> simpleObjs = decode(encoded);
    return simpleObjs;
  }
}