rate_my_app 0.6.0

Rate my app ! #

This plugin allows to kindly ask users to rate your app if custom conditions are met (eg. install time, number of launches, etc...). You can even add your own conditions.

Rate my app is really inspired by Android-Rate.

How to use #

Installation #

To target an iOS version before 10.3, add this in your Info.plist :


By the way, it's important to note that your bundle identifier (in your Info.plist) must match the App ID on iTunes Connect and the package identifier (in your build.gradle) must match your App ID on Google Play.

If for any reason it doesn't match please go to the Using custom identifiers section.

How it works #

Rate my app default constructor takes two main parameters (see Example for more info) :

  • minDays Minimum elapsed days since the first app launch.
  • minLaunches Minimum app launches count.

If everything above is verified, the method shouldOpenDialog will return true (false otherwise). Then you should call showRateDialog which is going to show a native rating dialog on iOS ≥ 10.3 and a custom rating prompt dialog on Android (and on older iOS versions).

If you prefer, you can call showStarRateDialog which will show a dialog containing a star rating bar that will allow you to take custom actions based on the rating (for example if the user puts less than 3 stars then open your app bugs report page or something like this and if he puts more ask him to rate your app on the store page).

Screenshots #

On Android #

showRateDialog method.

On iOS #

showRateDialog and showStarRateDialog method with ignoreIOS set to false.

Example #

// In this example, I'm giving a value to all parameters.
// Please note that not all are required (those that are required are marked with the @required annotation).

RateMyApp rateMyApp = RateMyApp(
  preferencesPrefix: 'rateMyApp_',
  minDays: 7,
  minLaunches: 10,
  remindDays: 7,
  remindLaunches: 10,
  googlePlayIdentifier: 'fr.skyost.example',
  appStoreIdentifier: '1491556149',

rateMyApp.init().then((_) {
  if (rateMyApp.shouldOpenDialog) {
      title: 'Rate this app', // The dialog title.
      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.', // The dialog message.
      rateButton: 'RATE', // The dialog "rate" button text.
      noButton: 'NO THANKS', // The dialog "no" button text.
      laterButton: 'MAYBE LATER', // The dialog "later" button text.
      listener: (button) { // The button click listener (useful if you want to cancel the click event).
        switch(button) {
          case RateMyAppDialogButton.rate:
            print('Clicked on "Rate".');
          case RateMyAppDialogButton.later:
            print('Clicked on "Later".');
          case RateMyAppDialogButton.no:
            print('Clicked on "No".');
        return true; // Return false if you want to cancel the click event.
      ignoreIOS: false, // Set to false if you want to show the native Apple app rating dialog on iOS.
      dialogStyle: DialogStyle(), // Custom dialog styles.
      onDismissed: () => rateMyApp.callEvent(RateMyAppEventType.laterButtonPressed), // Called when the user dismissed the dialog (either by taping outside or by pressing the "back" button).
      // actionsBuilder: (_) => [], // This one allows you to use your own buttons. 
    // Or if you prefer to show a star rating bar :
      title: 'Rate this app', // The dialog title.
      message: 'You like this app ? Then take a little bit of your time to leave a rating :', // The dialog message.
      actionsBuilder: (_, stars) { // Triggered when the user updates the star rating.
        return [ // Return a list of actions (that will be shown at the bottom of the dialog).
            child: Text('OK'),
            onPressed: () async {
              print('Thanks for the ' + (stars == null ? '0' : stars.round().toString()) + ' star(s) !');
              // You can handle the result as you want (for instance if the user puts 1 star then open your contact page, if he puts more then open the store page, etc...).
              // This allows to mimic the behavior of the default "Rate" button. See "Advanced > Broadcasting events" for more information :
              await rateMyApp.callEvent(RateMyAppEventType.rateButtonPressed);
              Navigator.pop<RateMyAppDialogButton>(context, RateMyAppDialogButton.rate);
      ignoreIOS: false, // Set to false if you want to show the native Apple app rating dialog on iOS.
      dialogStyle: DialogStyle( // Custom dialog styles.
        titleAlign: TextAlign.center,
        messageAlign: TextAlign.center,
        messagePadding: EdgeInsets.only(bottom: 20),
      starRatingOptions: StarRatingOptions(), // Custom star bar rating options.
      onDismissed: () => rateMyApp.callEvent(RateMyAppEventType.laterButtonPressed), // Called when the user dismissed the dialog (either by taping outside or by pressing the "back" button).

If you want a more complete example, please check this one on Github.
You can also follow the tutorial of Marcus Ng on YouTube (for a replacement of doNotOpenAgain, see Broadcasting events).

Advanced #

Using custom identifiers #

It's possible to use custom store identifiers ! Just pass the following parameters during the plugin initialization :

  • googlePlayIdentifier Your Google Play identifier (usually a package name).
  • appStoreIdentifier Your App Store identifier (usually numbers). It's required if you're targeting an iOS version before iOS 10.3.

Using custom conditions #

A condition is something required to be met in order for the shouldOpenDialog method to return true. Rate my app comes with three default conditions :

  • MinimumDaysCondition Allows to set a minimum elapsed days since the first app launch before showing the dialog.
  • MinimumAppLaunchesCondition Allows to set a minimum app launches count since the first app launch before showing the dialog.
  • DoNotOpenAgainCondition Allows to prevent the dialog from being opened (when the user clicks on the No button for example).

You can easily create your custom conditions ! All you have to do is to extend the Condition class. There are five methods to override :

  • readFromPreferences You should read your condition values from the provided shared preferences here.
  • saveToPreferences You should save your condition values to the provided shared preferences here.
  • reset You should reset your condition values here.
  • isMet Whether this condition is met.
  • onEventOccurred When an event occurs in the plugin lifecycle. This is usually here that you can update your condition values. Please note that you're not obligated to override this one (although this is recommended).

You can have an easy example of it by checking the source code of DoNotOpenAgainCondition.

Then you can add your custom condition to Rate my app by using the constructor customConditions (or by calling rateMyApp.conditions.add before initialization).

Broadcasting events #

As said in the previous section, the shouldOpenDialog method depends on conditions.

For example, when you click on the No button, this event will be triggered and the condition DoNotOpenAgainCondition will react to it and will stop being met and thus the shouldOpenDialog will return false.

You may want to broadcast events in order to mimic the behaviour of the No button for example. This can be done either by using the RateMyAppNoButton or you can directly call callEvent from your current RateMyApp instance in your button onTap callback.

Here are what events default conditions are listening to :

  • MinimumDaysCondition : Later button press.
  • MinimumAppLaunchesCondition : Rate my app initialization, Later button press.
  • DoNotOpenAgainCondition : Rate button press, No button press.

For example, starting from version 0.5.0, the getter/setter doNotOpenAgain has been removed. You must trigger the DoNotOpenAgainCondition either by calling a Rate button press event or a No button press event (see Example on Github).

Contributions #

You have a lot of options to contribute to this project ! You can :

Dependencies #

This library depends on some other libraries :

0.6.0 #

  • Added some styling options.
  • Now exposing the BuildContext in stars dialog.
  • Updated repository link.

0.5.0+4 #

  • Added the ability to run code when the dialog has been dismissed.
  • Added a dialog style that allows to change the content padding.

0.5.0+3 #

  • Updated README and added a link to Marcus Ng video on YouTube.

0.5.0+2 #

  • Updated README and added more details about what has been deleted.

0.5.0+1 #

  • Updated example and README.

0.5.0 #

  • Added a more modular condition system.
  • Updated smooth_star_rating (and thus allowing further star rating bar customizations).
  • Improved the README.md.
  • Now using AndroidX.

0.4.1+1 #

  • A little bug fixed when using a button listener.

0.4.1 #

  • Added the ability to attach a listener to the RateMyAppDialog buttons.

0.4.0 #

  • Moved some files to the src folder.
  • Added some options that allow you to tweak the dialogs look.

0.3.0+4 #

  • Updated README.

0.3.0+3 #

  • Changed the default stars border color.

0.3.0+2 #

  • Added an option to change the showStarRateDialog style.

0.3.0+1 #

  • Updated README.

0.3.0 #

  • Added an option to ignore iOS checks (when showing a dialog).
  • Added a showStarRateDialog method that allows to show a dialog with stars rating.

0.2.0+4 #

  • preferencesPrefix was not used. As it changes preference keys, this release resets Rate my app user preferences.
  • baseLaunchDate not affected by the Maybe Later button.

0.2.0+3 #

  • Fixed remindLaunches constantly triggering.

0.2.0+2 #

  • Updated README and examples.

0.2.0+1 #

  • Updated minimum SDK version.

0.2.0 #

  • Added the ability to use custom identifiers.
  • Removed a dependency.
  • Fixed a bug where the dialog was not closing after the user successfully clicked on "Rate".

0.1.0 #

  • First published release.


Examples #

If you want a "real project" example, you can check this one on Github.

If you want a little snippet, go to the projet page.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  rate_my_app: ^0.6.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:rate_my_app/rate_my_app.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Format lib/rate_my_app.dart.

Run flutter format to format lib/rate_my_app.dart.

Format lib/src/conditions.dart.

Run flutter format to format lib/src/conditions.dart.

Format lib/src/core.dart.

Run flutter format to format lib/src/core.dart.

Format lib/src/dialogs.dart.

Run flutter format to format lib/src/dialogs.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
pedantic ^1.9.0 1.9.0
shared_preferences ^0.5.6 0.5.6+2
smooth_star_rating ^1.0.4 1.0.4+2
Transitive dependencies
collection 1.14.11 1.14.12
flutter_web_plugins 0.0.0
meta 1.1.8
shared_preferences_macos 0.0.1+6
shared_preferences_platform_interface 1.0.3
shared_preferences_web 0.1.2+4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8