flutter_permission_validator 0.2.0
flutter_permission_validator: ^0.2.0 copied to clipboard
A CLI tool that analyzes Flutter projects to detect unused permissions in AndroidManifest.xml and Info.plist. Helps avoid app store rejections by ensuring permission declarations match actual usage in [...]
Flutter Permission Validator π #
A powerful CLI tool that analyzes your Flutter project to detect unused permissions in AndroidManifest.xml and Info.plist. Stop asking for permissions you don't use and avoid App Store rejections!
π― Why Use This? #
Mobile app stores have become increasingly strict about permission declarations:
- Avoid App Store Rejections: Apple and Google routinely reject apps that declare permissions they don't actually use. This is one of the most common reasons for app rejection.
- Privacy Compliance: Modern privacy regulations (GDPR, CCPA, App Store guidelines) require data minimization - only collecting data you actually need.
- Better User Trust: Users are more likely to trust apps that request fewer permissions. Excessive permissions can lead to bad reviews and low install rates.
- Reduce App Bloat: Clean up your manifest files and reduce technical debt.
- CI/CD Integration: Catch permission issues before they reach production with automated checks.
π Installation #
Option 1: Activate Globally (Recommended) #
This makes the perm_check command available system-wide:
# Activate the package globally
dart pub global activate flutter_permission_validator
# Verify installation
perm_check --help
Note: Make sure your PATH is set up correctly for global Dart tools:
- macOS/Linux: Add
~/.pub-cache/binto your PATH - Windows: Add
%LOCALAPPDATA%\Pub\Cache\binto your PATH
Option 2: Use Locally in a Project #
Add to your pubspec.yaml:
dev_dependencies:
flutter_permission_validator: ^0.2.0
Then run:
dart pub get
π Usage #
Basic Usage #
# Navigate to your Flutter project
cd my_flutter_app
# Run the validator (analyzes current directory)
perm_check
# Or specify a path
perm_check /path/to/flutter/project
# If using local installation
dart run flutter_permission_validator
dart run flutter_permission_validator /path/to/project
What Gets Analyzed #
The tool scans:
-
Android Permissions:
android/app/src/main/AndroidManifest.xml- Detects
<uses-permission>tags - Identifies 60+ Android permission types
- Detects
-
iOS Permissions:
ios/Runner/Info.plist- Detects
NS*UsageDescriptionkeys - Identifies 35+ iOS permission types
- Detects
-
Web Permissions: No manifest file needed
- Detects browser permission usage in code
- Identifies 6 Web permission types
-
Dart Code: All files in
lib/directory- API calls related to permissions
- Plugin imports and usage
- Package dependencies in
pubspec.yaml
Exit Codes #
- 0: No issues found (all permissions are properly used)
- 1: Issues found (unused or missing permissions detected)
This makes it perfect for CI/CD pipelines - the build will fail if permission issues are detected.
π Output Example #
π Flutter Permission Validator
π Project: /Users/dev/my_app
π± Analyzing Flutter permissions...
β
Android: 5 permissions declared
π /Users/dev/my_app/android/app/src/main/AndroidManifest.xml
β
iOS: 3 permissions declared
π /Users/dev/my_app/ios/Runner/Info.plist
π Scanning 42 Dart files...
β
Code scan: 2 Android permissions potentially used
β
Code scan: 2 iOS permissions potentially used
============================================================
π PERMISSION ANALYSIS RESULTS
============================================================
π± Android - Unused permissions:
β android.permission.ACCESS_FINE_LOCATION
β android.permission.RECORD_AUDIO
β android.permission.READ_CONTACTS
π± iOS - Unused permissions:
β NSMicrophoneUsageDescription
============================================================
Clean, simple output - Only shows unused permissions that can be safely removed from your manifests.
π¬ How It Works #
The analysis process involves four main steps:
-
Parse Manifest Files
- Locates
AndroidManifest.xmlin standard Flutter Android paths - Locates
Info.plistin standard Flutter iOS paths - Extracts all declared permissions
- Locates
-
Scan Dart Code
- Recursively scans all
.dartfiles inlib/ - Searches for permission-related patterns using regex
- Identifies API calls, imports, and class usages
- Recursively scans all
-
Analyze Dependencies
- Reads
pubspec.yamlfor package dependencies - Maps common packages to their required permissions
- Example:
geolocatorpackage β location permissions
- Reads
-
Compare and Report
- Matches declared permissions against detected usage
- Identifies unused permissions (declared but not used)
- Identifies missing permissions (used but not declared)
- Generates detailed report with actionable recommendations
π¨ Features #
Comprehensive Permission Detection #
| Feature | Android | iOS | Web |
|---|---|---|---|
| Camera | β
CAMERA |
β
NSCameraUsageDescription |
β
camera |
| Location | β
ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION |
β
NSLocationWhenInUseUsageDescription |
β
geolocation |
| Microphone | β
RECORD_AUDIO |
β
NSMicrophoneUsageDescription |
β
microphone |
| Storage | β
READ_EXTERNAL_STORAGE, READ_MEDIA_* |
β
NSPhotoLibraryUsageDescription |
β
storage |
| Contacts | β
READ_CONTACTS, WRITE_CONTACTS |
β
NSContactsUsageDescription |
N/A |
| Calendar | β
READ_CALENDAR, WRITE_CALENDAR |
β
NSCalendarsUsageDescription |
N/A |
| Bluetooth | β
BLUETOOTH_SCAN, BLUETOOTH_CONNECT |
β
NSBluetoothAlwaysUsageDescription |
N/A |
| Notifications | β
POST_NOTIFICATIONS |
β N/A (system) | β
notifications |
| Phone/SMS | β
READ_PHONE_STATE, SEND_SMS |
β N/A (sandboxed) | N/A |
| Health/Fitness | β
BODY_SENSORS |
β
NSHealthShareUsageDescription |
N/A |
| Face ID | N/A | β
NSFaceIDUsageDescription |
N/A |
| Siri | N/A | β
NSSiriUsageDescription |
N/A |
| Tracking | N/A | β
NSUserTrackingUsageDescription |
N/A |
Smart Package Detection #
The tool automatically detects permissions required by popular Flutter packages:
geolocatorβ Location permissionscameraβ Camera permissionsimage_pickerβ Camera/Photo Library permissionsflutter_contactsβ Contacts permissionsflutter_soundβ Audio recording permissionsflutter_blue/flutter_reactive_bleβ Bluetooth permissionsflutter_local_notificationsβ Notification permissionsshared_preferencesβ No permissions neededdevice_info_plusβ Device info permissionsconnectivity_plusβ Network state permissionspath_providerβ Storage access permissions- And 60+ more packages...
π¦ Supported Permission Patterns #
The tool uses sophisticated pattern matching to detect permission usage in your code:
Android Permissions (60+) #
Camera & Media
CAMERA- CameraController, ImagePicker, takePicture(), pickImage()
Location
ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION,ACCESS_BACKGROUND_LOCATION- Geolocator, getCurrentPosition(), getLocation()
Storage
READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE- FilePicker, Directory, File, path_providerREAD_MEDIA_IMAGES,READ_MEDIA_VIDEO,READ_MEDIA_AUDIO- PhotoManager, image_pickerMANAGE_EXTERNAL_STORAGE- File system management
Microphone & Audio
RECORD_AUDIO- AudioRecorder, record(), flutter_sound, audioplayers
Contacts & Accounts
READ_CONTACTS,WRITE_CONTACTS- Contacts, flutter_contactsGET_ACCOUNTS- google_sign_in, firebase_auth
Phone & SMS
READ_PHONE_STATE,READ_PHONE_NUMBERS,CALL_PHONE- device_info_plus, url_launcherREAD_CALL_LOG,ANSWER_PHONE_CALLS- Phone call managementSEND_SMS,READ_SMS,RECEIVE_SMS,RECEIVE_MMS- SMS handling
Calendar
READ_CALENDAR,WRITE_CALENDAR- Calendar, table_calendar
Bluetooth
BLUETOOTH,BLUETOOTH_ADMIN,BLUETOOTH_SCAN- flutter_blue, flutter_reactive_bleBLUETOOTH_CONNECT,BLUETOOTH_ADVERTISE- BLE operations
WiFi & Network
ACCESS_WIFI_STATE,CHANGE_WIFI_STATE- wifi_iot, network_info_plusNEARBY_WIFI_DEVICES- Nearby devices APIINTERNET,ACCESS_NETWORK_STATE- HTTP requests, connectivity checks
Sensors & Body
BODY_SENSORS,USE_SENSORS- Sensors, health, fitness, pedometerACTIVITY_RECOGNITION- Activity detection, step counting
Notifications
POST_NOTIFICATIONS- flutter_local_notifications, awesome_notifications
Alarms & Background
SCHEDULE_EXACT_ALARM,USE_EXACT_ALARM- android_alarm_managerRECEIVE_BOOT_COMPLETED- Auto-start on bootFOREGROUND_SERVICE,FOREGROUND_SERVICE_CAMERA,FOREGROUND_SERVICE_MICROPHONE,FOREGROUND_SERVICE_LOCATION- Background services
System & Hardware
VIBRATE- flutter_vibrateFLASHLIGHT- torch_lightUSE_BIOMETRIC,USE_FINGERPRINT- local_auth, biometric authenticationSYSTEM_ALERT_WINDOW- overlay_support, system overlaysREQUEST_INSTALL_PACKAGES,REQUEST_DELETE_PACKAGES- Package installationPACKAGE_USAGE_STATS- App usage trackingPROCESS_OUTGOING_CALLS- Call monitoringWRITE_SETTINGS- System settings
iOS Permissions (35+) #
Camera & Photos
NSCameraUsageDescription- CameraController, ImagePickerNSPhotoLibraryUsageDescription- ImagePicker, PhotoManagerNSPhotoLibraryAddUsageDescription- Saving photos to library
Location
NSLocationWhenInUseUsageDescription- Geolocator, getCurrentPosition()NSLocationAlwaysAndWhenInUseUsageDescription- Background locationNSLocationAlwaysUsageDescription- Always-on location
Audio & Speech
NSMicrophoneUsageDescription- AudioRecorder, record(), flutter_soundNSSpeechRecognitionUsageDescription- Speech-to-text, voice recognition
Contacts & Calendar
NSContactsUsageDescription- Contacts, flutter_contactsNSCalendarsUsageDescription- Calendar events, table_calendarNSRemindersUsageDescription- Reminders access
Bluetooth
NSBluetoothAlwaysUsageDescription- flutter_blue, BLE operationsNSBluetoothPeripheralUsageDescription- Bluetooth peripheral mode
Biometrics
NSFaceIDUsageDescription- local_auth, Face ID, Touch ID
Health & Fitness
NSMotionUsageDescription- Sensors, pedometer, accelerometer, gyroscopeNSHealthShareUsageDescription- Health data, fitness trackingNSHealthUpdateUsageDescription- Writing health dataNSHealthClinicalHealthRecordsShareUsageDescription- Clinical records
Home & Media
NSHomeKitUsageDescription- HomeKit integrationNSAppleMusicUsageDescription- Apple Music, audio playback
File Access
NSDocumentsFolderUsageDescription- Documents folderNSDesktopFolderUsageDescription- Desktop folderNSDownloadsFolderUsageDescription- Downloads folder
System Features
NSSiriUsageDescription- Siri integrationNSUserTrackingUsageDescription- App tracking transparencyNSFocusStatusUsageDescription- Focus status detectionNSCriticalAlertsUsageDescription- Critical alerts (bypass Do Not Disturb)NSPaymentsUsageDescription- Apple Pay integrationNSKeyboardExtensionUsageDescription- Custom keyboard extensions
Web Permissions (6+) #
Media
camera- CameraController, ImagePicker, getUserMedia()microphone- AudioRecorder, record(), getUserMedia()
Location & Storage
geolocation- Geolocator, getCurrentPosition(), navigator.geolocationstorage- File system access, Quota API, IndexedDBclipboard- Clipboard read/write, navigator.clipboard
System
notifications- Push notifications, Notification APIbackground-sync- Background synchronization, Service Workers
π License #
This project is licensed under the MIT License - see the LICENSE file for details.
π Additional Resources #
π Troubleshooting #
"Command not found: perm_check" #
Make sure you've added Dart's global bin directory to your PATH:
- macOS/Linux:
export PATH="$PATH:$HOME/.pub-cache/bin" - Windows: Add
%LOCALAPPDATA%\Pub\Cache\binto PATH
False Positives #
The tool uses pattern matching which may occasionally produce false positives:
- Review detected permissions before removing
- Check if dependencies require permissions indirectly
- Test your app after removing permissions
Missing File Warnings #
If you see warnings about missing manifest files:
- Ensure you're running from a valid Flutter project directory
- Check that
android/andios/folders exist - Verify
AndroidManifest.xmlandInfo.plistare in standard locations
Made with β€οΈ for the Flutter community