BaseTracker<T> class
abstract
An abstract base class for tracking values with expiration logic.
The BaseTracker
class provides a framework for tracking values that
can expire over time. It manages the storage and retrieval of these
values using a caching mechanism and ensures that the values are
refreshed when they expire.
Type parameter T
represents the type of the value being tracked.
- Inheritance
-
- Object
- BaseServiceObject
- BaseTracker
- Implementers
Constructors
- BaseTracker.new(String key, {required String suffix, bool useCache = false})
-
Constructs a BaseTracker with the specified
key
andsuffix
.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
lastUpdate
→ BasePrfObject<
DateTime> -
Provides access to the last update timestamp, considering the caching strategy.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- useCache → bool
-
Whether to use in-memory cache for performance.
finalinherited
-
value
→ BasePrfObject<
T> -
Provides access to the tracked value, considering the caching strategy.
no setter
Methods
-
clear(
) → Future< void> - Clears both the value and last update timestamp from storage.
-
fallbackValue(
) → T - Provides the fallback value for the tracked value.
-
get(
) → Future< T> - Retrieves the tracked value, resetting it if expired.
-
getLastUpdateTime(
) → Future< DateTime?> -
Retrieves the last update time, or
null
if never updated. -
hasState(
) → Future< bool> - Checks if either the value or timestamp exists in SharedPreferences.
-
isCurrentlyExpired(
) → Future< bool> - Determines if the tracker is currently expired.
-
isExpired(
DateTime now, DateTime? last) → bool - Determines if the tracked value is expired based on the current and last update times.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
peek(
) → Future< T> - Retrieves the value without resetting or updating it.
-
reset(
) → Future< void> - Resets the tracked value to its initial state.
-
timeSinceLastUpdate(
) → Future< Duration?> -
Calculates the duration since the last update, or
null
if never updated. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited