clearField method

void clearField(
  1. Field field,
  2. {required String savedTags,
  3. bool overrideLocks = false,
  4. bool notify = true}
)

Clear a controller for a particular field.

Implementation

void clearField(
  Field field, {
  required String savedTags,
  bool overrideLocks = false,
  bool notify = true,
}) {
  if (isLocked(field) && !overrideLocks) {
    return;
  } else {
    if (field is ImageExportField) {
      field.clearFieldState(creatorModel: this);
    } else if (field is AudioExportField) {
      field.clearFieldState(creatorModel: this);
    }

    /// Need to clear the audio/image seed when that's implemented as well.
    if (field is TagsField) {
      getFieldController(field).text = savedTags;
    } else {
      getFieldController(field).clear();
    }

    if (field is SentenceField) {
      getFieldController(SentenceField.instance).clear();
      getFieldController(ClozeBeforeField.instance).clear();
      getFieldController(ClozeInsideField.instance).clear();
      getFieldController(ClozeAfterField.instance).clear();
    }

    if (notify) {
      notifyListeners();
    }
  }
}