showRateDialog method
Future<void>
showRateDialog(
- BuildContext context, {
- String title = 'Rate this app',
- String message = 'If you like this app, please take a little bit of your time to review it !\nIt really helps us and it shouldn\'t take you more than one minute.',
- DialogContentBuilder? contentBuilder,
- DialogActionsBuilder? actionsBuilder,
- String rateButton = 'Rate',
- String noButton = 'No thanks',
- String laterButton = 'Maybe later',
- RateMyAppDialogButtonClickListener? listener,
- bool ignoreNativeDialog = false,
- DialogStyle dialogStyle = const DialogStyle(),
- VoidCallback? onDismissed,
- bool barrierDismissible = true,
- String barrierLabel = '',
- DialogTransition dialogTransition = const DialogTransition(),
Shows the rate dialog.
Implementation
Future<void> showRateDialog(
BuildContext context, {
String title = 'Rate this app',
String message =
'If you like this app, please take a little bit of your time to review it !\nIt really helps us and it shouldn\'t take you more than one minute.',
DialogContentBuilder? contentBuilder,
DialogActionsBuilder? actionsBuilder,
String rateButton = 'Rate',
String noButton = 'No thanks',
String laterButton = 'Maybe later',
RateMyAppDialogButtonClickListener? listener,
bool ignoreNativeDialog = false,
DialogStyle dialogStyle = const DialogStyle(),
VoidCallback? onDismissed,
bool barrierDismissible = true,
String barrierLabel = '',
DialogTransition dialogTransition = const DialogTransition(),
}) async {
if (!ignoreNativeDialog &&
((await isNativeReviewDialogSupported) ?? false)) {
callEvent(RateMyAppEventType.requestReview);
await launchNativeReviewDialog();
return;
}
RateMyAppDialog rateMyAppDialog = RateMyAppDialog(
this,
title: title,
message: message,
contentBuilder:
contentBuilder ?? ((context, defaultContent) => defaultContent),
actionsBuilder: actionsBuilder,
rateButton: rateButton,
noButton: noButton,
laterButton: laterButton,
listener: listener,
dialogStyle: dialogStyle,
);
callEvent(RateMyAppEventType.dialogOpen);
RateMyAppDialogButton? clickedButton;
if (context.mounted) {
// Using [showDialog()] when [TransitionType.none] to get rid of the default fading animation of [showGeneralDialog].
clickedButton = dialogTransition.transitionType == TransitionType.none
? await showDialog<RateMyAppDialogButton>(
context: context,
builder: (context) => rateMyAppDialog,
barrierDismissible: barrierDismissible,
)
: await showGeneralDialog<RateMyAppDialogButton>(
context: context,
barrierLabel: barrierLabel,
transitionDuration: dialogTransition.transitionDuration,
barrierDismissible: barrierDismissible,
transitionBuilder: dialogTransition.customTransitionBuilder ??
(context, animation1, animation2, child) => buildAnimations(
animation: animation1,
child: child,
dialogTransition: dialogTransition,
),
pageBuilder: (context, animation1, animation2) => rateMyAppDialog,
);
}
if (clickedButton == null && onDismissed != null) {
onDismissed();
}
}