showStarRateDialog method

Future<void> showStarRateDialog(
  1. BuildContext context, {
  2. String title = 'Rate this app',
  3. String message = 'You like this app ? Then take a little bit of your time to leave a rating :',
  4. DialogContentBuilder? contentBuilder,
  5. StarDialogActionsBuilder? actionsBuilder,
  6. bool ignoreNativeDialog = false,
  7. DialogStyle dialogStyle = const DialogStyle(titleAlign: TextAlign.center, messageAlign: TextAlign.center, messagePadding: EdgeInsets.only(bottom: 20)),
  8. StarRatingOptions starRatingOptions = const StarRatingOptions(),
  9. VoidCallback? onDismissed,
  10. bool barrierDismissible = true,
  11. String barrierLabel = '',
  12. DialogTransition dialogTransition = const DialogTransition(),
})

Shows the star rate dialog.

Implementation

Future<void> showStarRateDialog(
  BuildContext context, {
  String title = 'Rate this app',
  String message =
      'You like this app ? Then take a little bit of your time to leave a rating :',
  DialogContentBuilder? contentBuilder,
  StarDialogActionsBuilder? actionsBuilder,
  bool ignoreNativeDialog = false,
  DialogStyle dialogStyle = const DialogStyle(
    titleAlign: TextAlign.center,
    messageAlign: TextAlign.center,
    messagePadding: EdgeInsets.only(bottom: 20),
  ),
  StarRatingOptions starRatingOptions = const StarRatingOptions(),
  VoidCallback? onDismissed,
  bool barrierDismissible = true,
  String barrierLabel = '',
  DialogTransition dialogTransition = const DialogTransition(),
}) async {
  if (!ignoreNativeDialog &&
      ((await isNativeReviewDialogSupported) ?? false)) {
    callEvent(RateMyAppEventType.requestReview);
    await launchNativeReviewDialog();
    return;
  }

  assert(actionsBuilder != null, 'You should provide an actions builder.');
  callEvent(RateMyAppEventType.starDialogOpen);

  RateMyAppStarDialog starRateDialog = RateMyAppStarDialog(
    this,
    title: title,
    message: message,
    contentBuilder:
        contentBuilder ?? ((context, defaultContent) => defaultContent),
    actionsBuilder: actionsBuilder,
    dialogStyle: dialogStyle,
    starRatingOptions: starRatingOptions,
  );

  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(
            context: context, builder: (context) => starRateDialog)
        : await showGeneralDialog(
            context: context,
            transitionDuration: dialogTransition.transitionDuration,
            barrierLabel: barrierLabel,
            barrierDismissible: barrierDismissible,
            transitionBuilder: dialogTransition.customTransitionBuilder ??
                (context, animation1, animation2, child) => buildAnimations(
                      animation: animation1,
                      child: child,
                      dialogTransition: dialogTransition,
                    ),
            pageBuilder: (context, animation1, animation2) => starRateDialog,
          );
  }

  if (clickedButton == null && onDismissed != null) {
    onDismissed();
  }
}