load method

Future<void> load({
  1. bool forced = false,
})

load preference from local storage

Implementation

Future<void> load({bool forced = false}) async {
  String debugPrefix = '$runtimeType.load()';
  // Get Last save time
  bool different = await _loadTime();
  if (different || forced) {
    // Get Preference
    var pref = await _pref;
    String jsonString = pref.getString(key) ?? '{}';
    lazy.log('$debugPrefix:${jsonString.length}(byte)', forced: debugLogSave);
    Map<String, dynamic> json = jsonDecode(jsonString);
    lazy.log('$debugPrefix:json decoded', forced: debugLogSave);
    noSave(() => fromJson(json));
  } else {
    lazy.log('$debugPrefix:not loaded, already up to date',
        forced: debugLogSave);
  }
}