CachedContextProvider mixin
A caching mixin that ensures:
- Throttled collection (via cacheDuration)
- In‑flight deduplication (concurrent callers share one collection Future)
- Resilience (errors return
{}and do not break the pipeline)
The internal state is stored inside final wrapper cells to comply with
@immutable (fields themselves are final; only the inner values change).
- Superclass constraints
- Mixin applications
Properties
- cacheDuration → Duration
-
Cache TTL for this provider. Keep short for dynamic data, longer for static.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- manualReportOnly → bool
-
If true, this context is collected only for manual user‑initiated reports
(e.g., when the user taps "Send diagnostics"), and not for automatic
background reporting.
no setterinherited
- name → String
-
The key under which this provider's map is attached to the report context.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearCache(
) → void - Clears the cached value, forcing the next call to hit collect.
-
collect(
) → FutureOr< Map< String, dynamic> > - Override this instead of getData to implement the actual data collection.
-
getData(
) → Future< Map< String, dynamic> > -
Collects context data. Implementations must never throw; if an internal
error occurs, return an empty map instead.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validateData(
Map< String, dynamic> data) → bool -
Optional validation; return
trueto keep the data in the report. The default keeps any non‑empty map.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited