ReviewPromptTrigger class
Wraps child and calls maybeRequestReview every time
winStreakEvents fires (ENH-87) — the ready-to-use widget counterpart
to in_app_review_helper.dart's decision logic, which the rest of the
kit had no widget consuming at all before this. Same "core service has
timing logic → widget listener wired to it" pattern as
AchievementUnlockListener/AchievementService.
winStreakEvents is entirely caller-supplied — this widget doesn't
invent its own "happy moment" source (there's no single game-agnostic
event for that in this kit, unlike AchievementService.onUnlock). A
consumer app fires an event on it with the player's CURRENT win streak
count whenever a moment worth asking after happens (e.g. right after a
level win), and maybeRequestReview's own minWinStreak/cooldown
policy decides whether that particular event actually triggers a
prompt.
everDeclined is read fresh from State.widget on every event (not
cached at listen time), so a caller can flip it via setState on a
parent and have the very next event respect the new value.
A showReview that throws (or a missing StorageService
registration) is swallowed — same "never throws" defensive convention
as AchievementUnlockListener — since a review-prompt failure must
never crash the gameplay moment that triggered it.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ReviewPromptTrigger
Constructors
-
ReviewPromptTrigger({Key? key, required Widget child, required Stream<
int> winStreakEvents, required Future<void> showReview(), int minWinStreak = 3, bool everDeclined = false, Duration cooldown = const Duration(days: 30), VoidCallback? onRequested}) -
const
Properties
- child → Widget
-
final
- cooldown → Duration
-
final
- everDeclined → bool
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- minWinStreak → int
-
final
- onRequested → VoidCallback?
-
Fires after maybeRequestReview actually invoked showReview for a
given event — e.g. for a consumer to log an analytics event. Never
called when the policy decided NOT to prompt.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
showReview
→ Future<
void> Function() -
Forwarded to maybeRequestReview — the actual "show the native
prompt" call, injected by the consumer app (same seam convention as
every other concrete-SDK-free service in this kit).
final
-
winStreakEvents
→ Stream<
int> -
Emits the player's current win-streak count at each "happy moment" a
consumer app wants considered as a review-prompt opportunity.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ReviewPromptTrigger> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited