How to add In-App Review to flutter application

Kerim Yıldız
3 min readFeb 20, 2021

Google Play has recorded more then 3 million apps and Apple’s app store has 1.96 millions apps. Its so hard to find the right application in app markets and application markets are using special allgorithm named as Rating Algorithm for order and recommend best applications to users.

Rating Algorithms are using some parameters to rate an app. Some of there parameters are app’s name and app’s description but the most important parameters are app’s review and app’s rating.

So this library help you to increase your flutter application’s rate and review.

What is In-App Review

In-App Review actually is not a new feature for iOS devices. iPhone and iPad apps are using this feature for years but this feature added into Android devices yet (like Dec-2020).

In-App Review is so much better then bringing the user to app market because users dont need to exit the app for rating the app.

Installation

Go to https://pub.dev/packages/in_app_review to get last versions’s number and add this line into your pubspec.yaml file

in_app_review: ^1.0.4

Then run

flutter pub get

Import the libabry to your class

import ‘package:in_app_review/in_app_review.dart’;

Then use the following code for trigger the in app review at an android device.

final InAppReview inAppReview = InAppReview.instance;

if (await inAppReview.isAvailable()) {
inAppReview.requestReview();
}

Warning: There is an unknown limit for requst review.

Then you will see the following screen…

Warning: Do not try to test in app review in your android test device in debug mode because you cant get the rating page. You should use the internal app sharing for a right testing and be sure to you have not rate the app in your test device

If you are coding a cross platform applicatin you should use the following code for add Apple AppStore ID and(or) Microsoft Store ID to use the library.

final InAppReview inAppReview = InAppReview.instance;

inAppReview.openStoreListing(appStoreId: '...', microsoftStoreId: '...');

And here is the final code

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:in_app_review/in_app_review.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
final InAppReview _inAppReview = InAppReview.instance;
bool _isAvailable;

@override
void initState() {
super.initState();

WidgetsBinding.instance.addPostFrameCallback((_) {
_inAppReview
.isAvailable()
.then(
(bool isAvailable) => setState(
() => _isAvailable = isAvailable && !Platform.isAndroid,
),
)
.catchError((_) => setState(() => _isAvailable = false));
});
}
Future<void> _requestReview() => _inAppReview.requestReview();

Future<void> _openStoreListing() => _inAppReview.openStoreListing(
appStoreId: _appStoreId,
microsoftStoreId: _microsoftStoreId,
);

@override
Widget build(BuildContext context) {
const loadingMessage = 'LOADING';
const availableMessage = 'AVAILABLE';
const unavailableMessage = 'UNAVAILABLE';

return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('InAppReview Example')),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'InAppReview status: ${_isAvailable == null ? loadingMessage : _isAvailable ? availableMessage : unavailableMessage}',
),
RaisedButton(
onPressed: _requestReview,
child: Text('Request Review'),
),
RaisedButton(
onPressed: _openStoreListing,
child: Text('Open Store Listing'),
),
],
),
),
);
}
}

Test

You should test the app by uploading it to internal app sharing . Do not forget to remove your past review and ratings for the app for a right test.

Thanks for reading.

--

--

Kerim Yıldız
0 Followers

Hello. I m a Java and C# developer. I love to discover new things.