showAppFeedbackStarRatingDialog function

Future<void> showAppFeedbackStarRatingDialog(
  1. BuildContext context,
  2. String iOSUrlString,
  3. String androidUrlString, {
  4. required bool isHomeOwner,
})

Implementation

Future<void> showAppFeedbackStarRatingDialog(
  BuildContext context,
  String iOSUrlString,
  String androidUrlString, {
  required bool isHomeOwner,
}) {
  Navigator.of(context).pop();

  return showDialog(
    context: context,
    builder: (context) => Center(
      child: AlertDialog(
        actionsAlignment: MainAxisAlignment.spaceAround,
        title: Center(
          child: Column(
            children: [
              Image.asset(
                'assets/launcher/launcher.png',
                height: 60,
                width: 60,
              ),
              Text(
                context.sharedL10n.rateUs,
                style: context.textTheme.bodyLarge,
              ),
            ],
          ),
        ),
        content: Text(
          context.sharedL10n.starToRateNnAppStore,
          style: context.textTheme.titleSmall,
        ),
        actions: [
          Column(
            children: [
              RatingBar(
                alignment: Alignment.center,
                filledIcon: Icons.star,
                emptyIcon: Icons.star_border,
                onRatingChanged: (value) async {
                  if (value >= 3) {
                    openStoreUrl(context, iOSUrlString, androidUrlString)
                        .then((value) {
                      if (context.mounted) {
                        showAppFeedbackSubmitedDialog(context);
                      }
                    });
                  } else {
                    showAppFeedbackSubmissionDialog(
                      context: context,
                      isMoreThanThreeRates: true,
                      selectedStartCount: value,
                      isHomeOwner: isHomeOwner,
                    );
                  }
                },
                initialRating: 0,
                maxRating: 5,
                emptyColor: context.colorScheme.primary,
              ),
              TextButton(
                onPressed: () {
                  Navigator.of(context).pop();
                },
                child: Text(
                  context.sharedL10n.notNow,
                  style: context.textTheme.bodyMedium
                      ?.copyWith(color: context.colorScheme.primary),
                ),
              ),
            ],
          ),
        ],
      ),
    ),
  );
}