For my Flutter app I'm trying to access a List of Notebooks, this list is parsed from a file by the Api. I would like to avoid reading/parsing the file every time I call my notebooks getter, hence I would like something like this:
- if the file had already been parsed once, return the previously parsed List<Note>;
- else, read and parse the file, save the List<Note>and returns it.
I imagine something like this :
  List<Notebook> get notebooks {
    if (_notebooks != null) {
      return _notebooks;
    } else {
      return await _api.getNotebooks();
    }
  }
This code is not correct because I would need to mark the getter async and return a Future, which I don't want to. Do you know any solution for this problem, like caching values ? I also want to avoid initializing this list in my app startup and only parse once the first time the value is needed.
 
     
    