flutter macos permissions
A simple Flutter plugin to request Camera, Microphone, Notification ,Location ,FullDiskAccess ,Bluetooth and Screen & system audio recording permissions on macOS.
This plugin provides an easy-to-use API using method channels to handle macOS permissions in your Flutter desktop apps.
β¨ Features
π₯ Request Camera permission
π€ Request Microphone permission
π Request Notification permission
π Request Location permission
π ± Request Bluetooth permission
π₯ Request Screen & system audio recording permission
πΎ Check Full Disk Access permission
π Check current permission status
π Works with Flutter macOS desktop apps
How to use it ?
1. Add dependency
Add this to your package's pubspec.yaml file:
dependencies:
flutter_macos_permissions: <latest_version>
2. Install it You can install packages from the command line:
with pub :
$ pub get
with Flutter :
$ flutter pub get
3. Import it
Now in your Dart code, you can use :
import 'package:flutter_macos_permissions/flutter_macos_permissions.dart';
4.How to Use it ?
Sample app demonstrates how simple the usage of the library actually is.
Using flutter_macos_permissions in your project easy to intregate.
Build permission with FlutterMacosPermissions
πΉ Request permissions
- You can request permissions for Camera, Microphone, Notifications ,Location ,Screen & system audio recording ,FullDiskAccess and Bluetooth :
String status = "Idle";
/// Request Permission
void request(String type) async {
bool granted = false;
try {
switch (type) {
case 'camera':
granted = await FlutterMacosPermissions.requestCamera();
break;
case 'microphone':
granted = await FlutterMacosPermissions.requestMicrophone();
break;
case 'notification':
granted = await FlutterMacosPermissions.requestNotification();
break;
case 'requestLocation':
granted = await FlutterMacosPermissions.requestLocation();
break;
case 'requestFullDiskAccess':
granted = await FlutterMacosPermissions.requestFullDiskAccess();
print('fullDiskAccess request $granted');
break;
case 'requestScreenRecording':
granted = await FlutterMacosPermissions.requestScreenRecording();
break;
case 'requestBluetooth':
granted = await FlutterMacosPermissions.requestBluetooth();
break;
}
setState(() {
status = 'Requested $type β ${granted ? "Granted" : "Denied"}';
});
} catch (e) {
setState(() {
status = 'Error: $e';
});
}
}
Build UI buttons
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('MacOS Permissions')),
body: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 20),
/// Status Display
Container(
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey.shade400,
width: 2, // Border width
),
),
child: Text(status, style: const TextStyle(fontSize: 16)),
),
const SizedBox(height: 20),
/// camera permission and status
permissionCard(
'Camera',
Icons.camera_alt,
() => request('camera'),
() => checkStatus('cameraStatus'),
),
/// microphone permission and status
permissionCard(
'Microphone',
Icons.mic,
() => request('microphone'),
() => checkStatus('microphoneStatus'),
),
/// notification permission and status
permissionCard(
'Notifications',
Icons.notifications,
() => request('notification'),
() => checkStatus('notificationStatus'),
),
/// location permission and status
permissionCard(
'Location',
Icons.location_on,
() => request('requestLocation'),
() => checkStatus('locationStatus'),
),
/// screen recording permission and status
permissionCard(
'Screen & system audio recording',
Icons.screen_share,
() => request('requestScreenRecording'),
() => checkStatus('screenRecordingStatus'),
),
/// full disk access permission and status
permissionCard(
'Full Disk Access',
Icons.folder,
() => request('requestFullDiskAccess'),
() => checkStatus('fullDiskAccessStatus'),
),
/// bluetooth permission and status
permissionCard(
'Bluetooth',
Icons.bluetooth,
() => request('requestBluetooth'),
() => checkStatus('bluetoothStatus'),
),
],
),
),
);
}
πΈ Example
| without Any Permission | with Camera Permission |
|---|---|
| with Notification Permission | with Location Permission |
|---|---|
| with Bluetooth Permission | with FullDiskAccess Permission |
|---|---|
| with Microphone Permission | Screen & system audio recording Permission |
|---|---|
πΉ Check permission status
- You can also check the current status without requesting and with requesting.
- Status will return one of the following: authorized, denied, restricted, notDetermined.
/// Check Permission Status
void checkStatus(String type) async {
String status = 'Unknown';
try {
switch (type) {
case 'cameraStatus':
status = await FlutterMacosPermissions.cameraStatus();
break;
case 'microphoneStatus':
status = await FlutterMacosPermissions.microphoneStatus();
break;
case 'notificationStatus':
status = await FlutterMacosPermissions.notificationStatus();
break;
case 'locationStatus':
status = await FlutterMacosPermissions.locationStatus();
break;
case 'fullDiskAccessStatus':
status = await FlutterMacosPermissions.fullDiskAccessStatus();
break;
case 'screenRecordingStatus':
status = await FlutterMacosPermissions.screenRecordingStatus();
break;
case 'bluetoothStatus':
status = await FlutterMacosPermissions.bluetoothStatus();
break;
}
setState(() {
this.status = 'Status $type β $status';
});
} catch (e) {
setState(() => this.status = 'Error: $e');
}
}
Build UI buttons
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('MacOS Permissions')),
body: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 20),
/// Status Display
Container(
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey.shade400,
width: 2, // Border width
),
),
child: Text(status, style: const TextStyle(fontSize: 16)),
),
const SizedBox(height: 20),
/// camera permission and status
permissionCard(
'Camera',
Icons.camera_alt,
() => request('camera'),
() => checkStatus('cameraStatus'),
),
/// microphone permission and status
permissionCard(
'Microphone',
Icons.mic,
() => request('microphone'),
() => checkStatus('microphoneStatus'),
),
/// notification permission and status
permissionCard(
'Notifications',
Icons.notifications,
() => request('notification'),
() => checkStatus('notificationStatus'),
),
/// location permission and status
permissionCard(
'Location',
Icons.location_on,
() => request('requestLocation'),
() => checkStatus('locationStatus'),
),
/// screen recording permission and status
permissionCard(
'Screen & system audio recording',
Icons.screen_share,
() => request('requestScreenRecording'),
() => checkStatus('screenRecordingStatus'),
),
/// full disk access permission and status
permissionCard(
'Full Disk Access',
Icons.folder,
() => request('requestFullDiskAccess'),
() => checkStatus('fullDiskAccessStatus'),
),
/// bluetooth permission and status
permissionCard(
'Bluetooth',
Icons.bluetooth,
() => request('requestBluetooth'),
() => checkStatus('bluetoothStatus'),
),
],
),
),
);
}
πΈ Example
| Camera Status | Microphone Status | Screen & system audio recording Status |
|---|---|---|
| Notification Status | Location Status |
|---|---|
| Bluetooth Status | FullDiskAccess Status |
|---|---|
π Permission Properties
- The table below shows the available permissions, their method calls, possible status values, and the System Preferences location that can be opened if the user has denied access.
| Permission | Request Permission | Status Permission | Possible Status Values | Opens in System Preferences β Privacy & Security |
|---|---|---|---|---|
| Camera | FlutterMacosPermissions.requestCamera() |
FlutterMacosPermissions.cameraStatus() |
authorized, denied, restricted, notDetermined |
Camera |
| Microphone | FlutterMacosPermissions.requestMicrophone() |
FlutterMacosPermissions.microphoneStatus() |
authorized, denied, restricted, notDetermined |
Microphone |
| Notifications | FlutterMacosPermissions.requestNotification() |
FlutterMacosPermissions.notificationStatus() |
authorized, denied, notDetermined |
Notifications |
| Location | FlutterMacosPermissions.requestLocation() |
FlutterMacosPermissions.locationStatus() |
authorized, denied, restricted, notDetermined |
Location Services |
| Screen & system audio recording | FlutterMacosPermissions.requestScreenRecording() |
FlutterMacosPermissions.screenRecordingStatus() |
authorized, denied, restricted, notDetermined |
Screen & system audio recording |
| Bluetooth | FlutterMacosPermissions.requestBluetooth() |
FlutterMacosPermissions.bluetoothStatus() |
authorized, denied, restricted, notDetermined |
Bluetooth |
| FullDiskAccess | FlutterMacosPermissions.requestFullDiskAccess() |
FlutterMacosPermissions.fullDiskAccessStatus() |
authorized, denied, restricted, notDetermined |
Full Disk Access |
Bugs and Feedback
We welcome and appreciate any suggestions you may have for improvement. For bugs, questions, and discussions please use the GitHub Issues.
Acknowledgments
It extends Flutterβs foundation to provide a ready-to-use, customizable currency formatter widget.While Flutter and intl provide the base, flutter_macos_permissions simplifies the process by combining widgets and formatting logic into a single package you can drop into any app.
Contribution
The DashStack team enthusiastically welcomes contributions and project participation! There are a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing new features.
Credits
flutter_macos_permissions is owned and maintained by the Dashstack Infotech,Surat.
Follow us for updates and new releases π.