Skip to main content

in_app_review_pro 0.1.1 copy "in_app_review_pro: ^0.1.1" to clipboard
in_app_review_pro: ^0.1.1 copied to clipboard

Flutter plugin for showing the In-App Review/System Rating pop up on Android, iOS and MacOS. It makes it easy for users to rate your app.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:in_app_review_pro/in_app_review_pro.dart';

void main() => runApp(const InAppReviewExampleApp());

enum Availability { loading, available, unavailable }

class InAppReviewExampleApp extends StatefulWidget {
  const InAppReviewExampleApp({super.key});

  @override
  State<InAppReviewExampleApp> createState() => _InAppReviewExampleAppState();
}

class _InAppReviewExampleAppState extends State<InAppReviewExampleApp> {
  final InAppReview _inAppReview = InAppReview.instance;
  String _appStoreId = '';
  String _microsoftStoreId = '';
  Availability _availability = Availability.loading;
  bool _busy = false;
  final _messengerKey = GlobalKey<ScaffoldMessengerState>();

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

  Future<void> _checkAvailability() async {
    var available = false;
    try {
      available = await _inAppReview.isAvailable();
    } catch (_) {
      // A third-party platform implementation may throw here.
    }
    if (!mounted) return;
    setState(
      () => _availability = available
          ? Availability.available
          : Availability.unavailable,
    );
  }

  Future<void> _run(Future<void> Function() operation) async {
    setState(() => _busy = true);
    try {
      await operation();
    } catch (error) {
      if (!mounted) return;
      _messengerKey.currentState?.showSnackBar(
        SnackBar(content: Text('$error')),
      );
    } finally {
      if (mounted) setState(() => _busy = false);
    }
  }

  @override
  Widget build(BuildContext context) {
    final platform = defaultTargetPlatform;
    return MaterialApp(
      scaffoldMessengerKey: _messengerKey,
      title: 'In App Review Example',
      home: Scaffold(
        appBar: AppBar(title: const Text('In App Review Example')),
        body: ListView(
          padding: const EdgeInsets.all(16),
          children: [
            Text('In App Review status: ${_availability.name}'),
            const Text(
              'A successful request does not guarantee a review dialog. '
              'On Android, test through Google Play internal testing.',
            ),
            if (platform == TargetPlatform.iOS ||
                platform == TargetPlatform.macOS)
              TextField(
                onChanged: (id) => _appStoreId = id.trim(),
                decoration: const InputDecoration(hintText: 'App Store ID'),
                keyboardType: TextInputType.number,
              ),
            if (platform == TargetPlatform.windows)
              TextField(
                onChanged: (id) => _microsoftStoreId = id.trim(),
                decoration: const InputDecoration(
                  hintText: 'Microsoft Store ID',
                ),
              ),
            ElevatedButton(
              onPressed: !_busy && _availability == Availability.available
                  ? () => _run(_inAppReview.requestReview)
                  : null,
              child: const Text('Request Review'),
            ),
            ElevatedButton(
              onPressed: _busy
                  ? null
                  : () => _run(
                      () => _inAppReview.openStoreListing(
                        appStoreId: _appStoreId,
                        microsoftStoreId: _microsoftStoreId,
                      ),
                    ),
              child: const Text('Open Store Listing'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
223
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for showing the In-App Review/System Rating pop up on Android, iOS and MacOS. It makes it easy for users to rate your app.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, plugin_platform_interface, url_launcher_platform_interface, url_launcher_windows

More

Packages that depend on in_app_review_pro

Packages that implement in_app_review_pro