gt_permission 1.0.0 copy "gt_permission: ^1.0.0" to clipboard
gt_permission: ^1.0.0 copied to clipboard

A comprehensive Flutter permission handler utility with singleton pattern, platform-specific version handling, error management, and user-friendly result objects for all iOS and Android permissions.

GT Permission #

pub package License: MIT

A comprehensive Flutter permission handler utility with singleton pattern, platform-specific version handling, and user-friendly result objects for all iOS and Android permissions.

Features #

  • πŸ” Singleton Pattern - Easy access throughout your app
  • πŸ“± Platform-Specific Handling - Android 13+, iOS 14+ version-aware
  • πŸ“Š Rich Result Objects - Detailed status info with user-friendly messages
  • 🎨 Adaptive Dialogs - Material (Android) and Cupertino (iOS) dialogs
  • ⚑ 40+ Permission Methods - Camera, location, storage, Bluetooth, notifications, and more
  • πŸ”„ Smart Fallbacks - Handles legacy and modern permission APIs

Installation #

Add to your pubspec.yaml:

dependencies:
  gt_permission: ^1.0.0

Then run:

flutter pub get

Platform Setup #

Android #

Add permissions to android/app/src/main/AndroidManifest.xml:

<!-- Common permissions -->
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<!-- Add more as needed - see PERMISSION.md for complete list -->

iOS #

Add to ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>We need camera access to take photos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need photo library access to select photos</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location while using the app</string>
<!-- Add more as needed -->

Configure ios/Podfile to enable permissions (see documentation for full list).

Quick Start #

Request Single Permission #

import 'package:gt_permission/gt_permission.dart';

final permissionUtil = PermissionHandlerUtil.instance;

// Request camera permission
final result = await permissionUtil.requestCameraPermission();

if (result.isGranted) {
  // Permission granted - open camera
  print('Camera access granted!');
} else if (result.isPermanentlyDenied) {
  // Show dialog to open settings
  await permissionUtil.openAppSettings();
} else {
  // Permission denied
  print('Denied: ${result.message}');
}

Request Multiple Permissions #

final statuses = await permissionUtil.requestMultiplePermissions([
  Permission.camera,
  Permission.microphone,
  Permission.storage,
]);

bool allGranted = statuses.values.every((s) => s.isGranted);

Check Permission Status #

bool hasCamera = await permissionUtil.isPermissionGranted(Permission.camera);
bool isPermanentlyDenied = await permissionUtil.isPermissionPermanentlyDenied(Permission.location);

Show Platform-Adaptive Dialog #

import 'package:gt_permission/gt_permission.dart';

await PermissionDialogUtils.showResultDialog(
  context,
  result,  // PermissionRequestResult
  Permission.camera,
);

Available Permission Methods #

Method Description
requestCameraPermission() Camera access
requestMicrophonePermission() Microphone/audio recording
requestLocationPermission() Foreground location
requestLocationAlwaysPermission() Background location
requestPhotosPermission() Photo library (Android 13+: READ_MEDIA_IMAGES)
requestVideosPermission() Video access (Android 13+)
requestStoragePermission() Storage (version-aware)
requestNotificationPermission() Push notifications
requestBluetoothPermission() Bluetooth (version-aware)
requestContactsPermission() Contacts access
requestCalendarPermission() Calendar events

...and many more! See documentation for complete list.

PermissionRequestResult #

Every request returns a PermissionRequestResult with:

result.isGranted          // Permission granted
result.isDenied           // Denied but can request again
result.isPermanentlyDenied // Must open settings
result.isLimited          // Limited access (iOS 14+ photos)
result.message            // User-friendly message
result.shouldOpenSettings // Suggests opening settings

License #

MIT License - see LICENSE for details.

0
likes
140
points
143
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter permission handler utility with singleton pattern, platform-specific version handling, error management, and user-friendly result objects for all iOS and Android permissions.

Repository (GitHub)
View/report issues

Topics

#permissions #permission-handler #android #ios #utilities

Documentation

API reference

License

MIT (license)

Dependencies

device_info_plus, flutter, permission_handler

More

Packages that depend on gt_permission