# QuickAction.addToPrefs constructor

QuickAction.addToPrefs(

1. QuickActionItem item

)

## Implementation

    QuickAction.addToPrefs(QuickActionItem item) {
      // Get old lists
      List<String> quickSettingsTitles =
          prefs.getStringList('quickSettingsTitles') ?? [];
      List<String> quickSettingsContents =
          prefs.getStringList('quickSettingsContents') ?? [];

      // Add to list
      if (!quickSettingsTitles.contains(item.name)) {
        quickSettingsTitles.add(item.name);
        quickSettingsContents.add(item.content);
      }
      // Edit if already exists
      else {
        int index = quickSettingsTitles.indexOf(item.name);
        quickSettingsContents[index] = item.content;
      }

      // Set shared prefs
      prefs.setStringList('quickSettingsTitles', quickSettingsTitles);
      prefs.setStringList('quickSettingsContents', quickSettingsContents);
      prefs.setString('quickSettingsMeta_${item.name}', item.toYamlString());
    }