save method

Future<void> save({
  1. DateTime? dateTime,
  2. Function? saved,
  3. String debugMsg = '',
  4. bool noSaveTime = false,
})

Save preference to local storage

  • Automatically update and save lastSaveTime
  • debugMsg : easier to trace caller
  • dateTime : manually set the save time. Default is null and current time is used.
  • noSaveTime : set to true in case you don't want to update the save time. Default is false.
  • saved : a callback function to be executed when save is finished
  • Do not override.

Implementation

Future<void> save({
  DateTime? dateTime,
  Function? saved,
  String debugMsg = '',
  bool noSaveTime = false,
}) async {
  // Set pending flag
  if (_noSave == 0) {
    String debugPrefix = '$debugMsg -> $runtimeType.save()';
    // Set pending
    lazy.log(debugPrefix, forced: debugLogSave);
    _saveWait(
      debugMsg: debugPrefix,
      dateTime: dateTime,
      noSaveTime: noSaveTime,
      saved: saved,
    );
  }
}