FeedbackTrigger class
Determines when to proactively prompt for feedback based on usage signals.
Tracks app launches and install time via SharedPreferences. Call recordLaunch once per app start, then check shouldShow at a suitable moment (e.g. after a key user action).
final trigger = FeedbackTrigger(minAppLaunches: 5, minDaysInstalled: 3);
await trigger.recordLaunch();
if (await trigger.shouldShow()) {
// show FeedbackButton or open FeedbackWidget manually
await trigger.markShown();
}
Constructors
- FeedbackTrigger({int minAppLaunches = 5, int minDaysInstalled = 3, int repeatAfterDays = 60, bool oncePerVersion = false})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- minAppLaunches → int
-
Minimum number of app launches before showing the prompt. Default: 5.
final
- minDaysInstalled → int
-
Minimum days since first launch before showing the prompt. Default: 3.
final
- oncePerVersion → bool
-
If
true, show at most once per app version.final - repeatAfterDays → int
-
How many days to wait before showing the prompt again. Default: 60.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
markNeverShow(
) → Future< void> - Permanently suppresses the prompt (user chose "Never ask again").
-
markShown(
{String? appVersion}) → Future< void> - Records that the prompt was shown. Call this after displaying the widget.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recordLaunch(
) → Future< void> - Records an app launch and initialises the install timestamp on first run.
-
reset(
) → Future< void> - Resets all trigger state. Useful during testing.
-
shouldShow(
{String? appVersion}) → Future< bool> -
Returns
truewhen all conditions are met and the prompt should appear. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited