Introduction

In this article, we will learn how to implement an app review feature in a Flutter app. To add the review feature in Flutter applications, we will use app_review plugin. In Android, the app review will redirect you to Google Play Store and in iOS, it will open a popup for you to write the app review. So, let’s start implementing it.
Output
App Review Implementation In Flutter

Methods

  1. AppReview.getAppID: This method will return the application id
  2. AppReview.storeListing: This method is for Android app review and it will redirect the user to Google Play Store for reviewing the app.
  3. AppReview.requestReview: This method is for the iOS app and it will open a popup to review the app.
Plugin Required
app_review: ^1.0.0

Steps

Step 1
The first and most basic step is to create a new application in Flutter. If you are a beginner, then you can check my blog Create your first app in Flutter. I have created an app named as “flutter_app_review”.
Step 2
Now, we will configure intro_views_flutter plugin in pubspec.yaml file.
  1. dependencies:
  2. flutter:
  3. sdk: flutter
  4. cupertino_icons: ^0.1.2
  5. app_review: ^1.0.0
Step 3
Now, we will implement the app review functionality for Android and iOS both. All the above-explained methods will be implemented in the main.dart file. Following is the programming implementation for that.
  1. import 'package:flutter/material.dart';
  2. import 'package:app_review/app_review.dart';
  3. void main() => runApp(MyApp());
  4. class MyApp extends StatelessWidget {
  5. @override
  6. Widget build(BuildContext context) {
  7. return MaterialApp(
  8. theme: ThemeData(
  9. primarySwatch: Colors.blue,
  10. ),
  11. home: MyHomePage(),
  12. );
  13. }
  14. }
  15. class MyHomePage extends StatefulWidget {
  16. @override
  17. _MyHomePageState createState() => _MyHomePageState();
  18. }
  19. class _MyHomePageState extends State<MyHomePage> {
  20. String appID = "";
  21. String output = "";
  22. @override
  23. void initState() {
  24. super.initState();
  25. AppReview.getAppID.then((onValue) {
  26. setState(() {
  27. appID = onValue;
  28. });
  29. print("App ID" + appID);
  30. });
  31. }
  32. @override
  33. Widget build(BuildContext context) {
  34. return Scaffold(
  35. appBar: AppBar(
  36. title: Text('Flutter App Review'),
  37. ),
  38. body: SingleChildScrollView(
  39. child: new ListBody(
  40. children: <Widget>[
  41. new Container(
  42. height: 40.0,
  43. ),
  44. new ListTile(
  45. leading: new Icon(Icons.info),
  46. title: new Text('App ID'),
  47. subtitle: new Text(appID),
  48. onTap: () {
  49. AppReview.getAppID.then((onValue) {
  50. setState(() {
  51. output = onValue;
  52. });
  53. print(onValue);
  54. });
  55. },
  56. ),
  57. new Divider(
  58. height: 20.0,
  59. ),
  60. new ListTile(
  61. leading: new Icon(
  62. Icons.shop,
  63. ),
  64. title: new Text('View Store Page'),
  65. onTap: () {
  66. AppReview.storeListing.then((onValue) {
  67. setState(() {
  68. output = onValue;
  69. });
  70. print(onValue);
  71. });
  72. },
  73. ),
  74. new Divider(
  75. height: 20.0,
  76. ),
  77. new ListTile(
  78. leading: new Icon(
  79. Icons.star,
  80. ),
  81. title: new Text('Request Review'),
  82. onTap: () {
  83. AppReview.requestReview.then((onValue) {
  84. setState(() {
  85. output = onValue;
  86. });
  87. print(onValue);
  88. });
  89. },
  90. ),
  91. new Divider(
  92. height: 20.0,
  93. ),
  94. new ListTile(
  95. leading: new Icon(
  96. Icons.note_add,
  97. ),
  98. title: new Text('Write a New Review'),
  99. onTap: () {
  100. AppReview.writeReview.then((onValue) {
  101. setState(() {
  102. output = onValue;
  103. });
  104. print(onValue);
  105. });
  106. },
  107. ),
  108. new Divider(
  109. height: 20.0,
  110. ),
  111. new ListTile(
  112. title: new Text(output),
  113. ),
  114. ],
  115. ),
  116. ),
  117. );
  118. }
  119. }
Hooray…. Run the app and test it on an emulator/simulator or a device.

Conclusion

We have learned how to implement the app review feature in a Flutter application.
Git Repo