showPromoterSurvey method
Probably shows the Promoter Score survey depending on options
,
specifically PsOptions.frequency, PsOptions.initialDelay and
PsOptions.minimumAppStarts settings.
Wiredash decides whether it is a good time to show the promoter score survey or not, making sure your users don't see the promoter score survey too often while maintaining a continuous stream of promoter score ratings.
Use force
to explicitly show open the promoter score survey.
This is useful when you want to trigger the flow at specific/rare times
in your business logic.
E.g. a user has paired their Action camera and transferred more than three
pictures.
This method returns true
when the flow got opened or false
when it was
not a good time to show it.
When providing options
, those settings will be used, overwriting the
ones defined in Wiredash.psOptions.
The options
will then be merged with defaultPsOptions, filling your
null
values
Implementation
Future<bool> showPromoterSurvey({
bool? inheritMaterialTheme,
bool? inheritCupertinoTheme,
PsOptions? options,
bool? force,
}) async {
_captureAppTheme(inheritMaterialTheme, inheritCupertinoTheme);
_captureAppLocale();
_model.psOptionsOverride = options;
if (force == true) {
await _model.show(flow: WiredashFlow.promoterScore);
return true;
} else {
final actualOptions = _model.psOptions;
final properties = DiagnosticPropertiesBuilder();
final trigger = _model.services.psTrigger;
final shouldShow = await trigger.shouldShowPromoterSurvey(
options: actualOptions,
diagnosticProperties: properties,
);
if (shouldShow) {
await _model.show(flow: WiredashFlow.promoterScore);
return true;
} else {
final reasons = properties.properties.join('\n - ');
// ignore: avoid_print
print(
'Wiredash: Not showing promoter score survey because:\n - $reasons',
);
if (kDebugMode) {
print(
'For testing, use Wiredash.of(context).showPromoterSurvey(force: true);',
);
}
return false;
}
}
}