PendingPreferences class
Manages pending (unsaved) food preference changes during the preferences wizard.
This class acts as a temporary buffer between the UI and UserPreferences, allowing users to make multiple preference changes before committing them. Changes are stored in memory and only persisted when saveAll is called.
Key responsibilities:
- Tracks pending attribute importance changes (e.g., nutrition, allergens)
- Manages the list of unwanted ingredients
- Supports project-specific preferences (foods, beauty, pets, etc.)
- Provides methods to query and modify pending preferences
Use saveAll to persist all pending changes to UserPreferences.
- Inheritance
-
- Object
- ChangeNotifier
- PendingPreferences
- Available extensions
Constructors
-
PendingPreferences({required UserPreferences userPreferences, required List<
AttributeGroup> attributeGroups, required PreferencesPageProjects project})
Properties
-
attributeGroups
→ List<
AttributeGroup> -
no setter
- hasAnySelection → bool
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- project → PreferencesPageProjects
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
unwantedIngredients
→ List<
String> -
no setter
- unwantedIngredientsInitialized → bool
-
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addUnwantedIngredient(
String ingredient) → void -
dispose(
) → void -
Discards any resources used by the object.
inherited
-
getImportanceIdForAttributeId(
String attributeId) → String -
getSelectedAttributesForGroup(
AttributeGroup group) → List< Attribute> -
isAttributeEnabled(
String attributeId) → bool -
isIngredientExcluded(
String ingredient) → bool -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeUnwantedIngredient(
String ingredient) → void -
replaceListener(
VoidCallback listener) → void -
Available on ChangeNotifier, provided by the ChangeNotifierExtensions extension
-
saveAll(
) → Future< void> -
setImportance(
String attributeId, String importanceId) → void -
toggleAttribute(
String attributeId) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- disabledImportanceId → const String
- enabledImportanceId → const String