dismiss method

void dismiss(
  1. Survey survey,
  2. bool permanently
)

Invoking this method will persist the survey's id in the local file with either a snooze or permanently dismissed indicator.

In the snoozed state, the survey will be prompted again after the survey's specified snooze period.

Each entry for a survey will have the following format:

{
  "survey-unique-id": {
    "status": "snoozed",  // status is either snoozed or dismissed
    "timestamp": 1690219834859
  }
}

Implementation

void dismiss(Survey survey, bool permanently) {
  final contents = _parseJsonFile();

  // Add the new data and write back out to the file
  final status = permanently ? 'dismissed' : 'snoozed';
  contents[survey.uniqueId] = {
    'status': status,
    'timestamp': clock.now().millisecondsSinceEpoch,
  };

  _dismissedSurveyFile.writeAsStringSync(jsonEncode(contents));
}