riverpod_permissions 0.0.4 copy "riverpod_permissions: ^0.0.4" to clipboard
riverpod_permissions: ^0.0.4 copied to clipboard

A Flutter package for managing permissions with Riverpod.

riverpod_permissions #

A UI wrapper around permission_handler with Riverpod state management. Handles common patterns like re-checking permissions on app resume and automatically detecting permanently denied permissions to redirect users to Settings.

Permission Splash Screen      Permanently Denied — Open Settings

Getting started #

1. Install #

dependencies:
  riverpod_permissions: ^0.0.4

2. Platform setup #

Follow the permission_handler setup guide for each platform you target (iOS Info.plist, Android AndroidManifest.xml, etc.).

3. Initialise #

import 'package:riverpod_permissions/riverpod_permissions.dart';

void main() {
  RiverpodPermissions.initialize(
    RiverpodPermissionsConfig(
      brandingWidget: Image.asset('assets/logo.png'),
    ),
  );
  runApp(const ProviderScope(child: MyApp()));
}

Features #

Riverpod provider #

Listen to any permission's state with permissionRepositoryProvider:

final contactsPerm = ref.watch(permissionRepositoryProvider(Permission.contacts));

switch (contactsPerm) {
  case AsyncData(:final value):
    if (value.isAvailable) {
      // Permission granted — show feature
    }
  case AsyncError(:final error):
    // Handle error
  case _:
    // Loading
}

Permission splash screen #

Use convenience constructors for common permissions:

Navigator.of(context).push(
  MaterialPageRoute(
    builder: (_) => PermissionSplashScreen.contacts(
      onComplete: () => Navigator.of(context).pop(),
      detailsBuilder: (TextSpan permissionName) => <TextSpan>[
        TextSpan(text: 'How we use your '),
        permissionName,
        TextSpan(
          text:
              ' data - when you add a transaction with someone in your contacts, we only take the phone number which you have stored for that user and upload it to the server. Nothing else is taken from your ',
        ),
        permissionName,
        TextSpan(text: ', not even the name of the person. '),
      ],
    ),
  ),
);

Or the general constructor for any permission:

PermissionSplashScreen(
  permission: Permission.microphone,
  permissionName: 'Microphone',
  onComplete: () => Navigator.of(context).pop(),
)

Permanently denied detection #

When a user permanently denies a permission (or revokes it via system settings), the splash screen automatically detects this and transforms the UI:

  • A warning banner appears explaining that the permission must be granted from Settings
  • The action button changes from "Continue" to "Open Settings", which deep-links directly into your app's system settings page

This is handled entirely by the package — no extra code required. The same PermissionSplashScreen widget adapts its UI based on the current permission state, including when the user returns from Settings via app resume detection.

Additional information #