showReview method

dynamic showReview(
  1. BuildContext context,
  2. dynamic onSubmit(
    1. MapEntry<int, String>? feedback,
    2. String? description
    ),
  3. dynamic onGoodRating(
    1. dynamic setKey()
    )
)

Implementation

showReview(
    BuildContext context,
    Function(MapEntry<int, String>? feedback, String? description) onSubmit,
    Function(Function() setKey) onGoodRating) async {
  final canShow = await GlobalAdVariables.canShowReview();
  if (canShow) {
    showAdaptiveDialog(
      context: context,
      builder: (context) {
        return StatefulBuilder(
          builder: (context, setState) {
            return ValueListenableBuilder(
              valueListenable: GlobalAdVariables.ratingBar,
              builder: (context, value, child) {
                return AlertDialog.adaptive(
                  titleTextStyle: TextStyle(
                    fontWeight: FontWeight.bold,
                  ),
                  title: Text(
                    "Tell us your Experience",
                    textAlign: TextAlign.left,
                  ),
                  content: Column(
                    children: [
                      SizedBox(
                        height: 10,
                      ),
                      RatingBarEmoji(
                        imageSize: 40,
                        showFeedbackForRatingsLessThan: 4,
                        submitButtonTitle: "Rate",
                        feedbackUIType: FeedbackUIType.alertBox,
                        showRedirectToStoreForRatingsGreaterThan: 3,
                        onSubmitTap: (selectedFeedback, description) async {
                          await RewardHelper.submitFeedBack(
                              rate: value.toString(),
                              description: description ?? "",
                              type: selectedFeedback?.value ?? "");
                          onSubmit(selectedFeedback, description);
                        },
                        lowRatingFeedback: [
                          "Too Many Ads",
                          "Crashed More Often",
                          "Rewards not Working",
                          "Slow and laggy",
                        ],
                        currentRating: value,
                        onRatingChanged: (rating) {
                          GlobalAdVariables.ratingBar =
                              ValueNotifier<double>(rating);
                          if (rating > 3) {
                            onGoodRating(
                              () async {
                                await GlobalAdVariables.setReviewProcess();
                              },
                            );
                            return;
                          }
                          setState(() {});
                        },
                      ),
                      SizedBox(
                        height: 10,
                      ),
                      Text("Rate us to help us improve app"),
                    ],
                  ),
                );
              },
            );
          },
        );
      },
    );
  }
}