fix: microphone permission for MacOS#3182
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds macOS-specific microphone permission handling using a new plugin and updates macOS app configuration to declare microphone usage. Sequence diagram for macOS-specific microphone permission requestsequenceDiagram
actor User
participant ChannelParametersWidget
participant Platform
participant PermissionHandler
participant FlutterMacosPermissions
participant MacOS
participant OtherOS
User->>ChannelParametersWidget: toggleInBuiltMIC(value)
ChannelParametersWidget->>Platform: isMacOS
alt Platform_is_macOS
ChannelParametersWidget->>FlutterMacosPermissions: requestMicrophone()
FlutterMacosPermissions->>MacOS: request_microphone_permission
MacOS-->>FlutterMacosPermissions: permission_status
FlutterMacosPermissions-->>ChannelParametersWidget: permission_status
else Platform_is_not_macOS
ChannelParametersWidget->>PermissionHandler: Permission.microphone.request()
PermissionHandler->>OtherOS: request_microphone_permission
OtherOS-->>PermissionHandler: permission_status
PermissionHandler-->>ChannelParametersWidget: permission_status
end
ChannelParametersWidget->>ChannelParametersWidget: setState(update_inBuiltMIC_selection)
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Introducing
flutter_macos_permissionsunder GPL-3.0 may have licensing implications for the overall project; please confirm this is compatible with the app’s current license and distribution model or consider a more permissively licensed alternative. - The platform-specific permission handling is now embedded directly in
ChannelParametersWidget; consider extracting this mic permission logic into a dedicated service or helper so that platform differences are centralized and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Introducing `flutter_macos_permissions` under GPL-3.0 may have licensing implications for the overall project; please confirm this is compatible with the app’s current license and distribution model or consider a more permissively licensed alternative.
- The platform-specific permission handling is now embedded directly in `ChannelParametersWidget`; consider extracting this mic permission logic into a dedicated service or helper so that platform differences are centralized and easier to maintain.
## Individual Comments
### Comment 1
<location path="lib/view/widgets/channel_parameters_widget.dart" line_range="255" />
<code_context>
oscilloscopeStateProvider.isInBuiltMICSelected,
onChanged: (bool? value) async {
- await Permission.microphone.request();
+ if (Platform.isMacOS) {
+ await FlutterMacosPermissions.requestMicrophone();
+ }else{
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard `Platform.isMacOS` usage to avoid issues on web/unsupported platforms.
Using `Platform` from `dart:io` inside a widget will cause web builds (and any target without `dart:io`) to fail to compile. If this widget can appear in a web build, use a conditional approach (e.g. `kIsWeb`, conditional imports, or platform‑specific entry points) so `Platform` is never referenced on unsupported targets. Otherwise, ensure this code is isolated to desktop/mobile code paths that are not compiled for web.
</issue_to_address>
### Comment 2
<location path="macos/Runner/Info.plist" line_range="33-34" />
<code_context>
<string>NSApplication</string>
<key>NSLocationUsageDescription</key>
<string>This app needs access to location.</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Some message to describe why you need this permission</string>
</dict>
</plist>
</code_context>
<issue_to_address>
**suggestion:** Use a concrete, user-facing microphone usage description string.
The `NSMicrophoneUsageDescription` is still a placeholder. Since this text appears in the macOS permission prompt, please replace it with a specific explanation of how the app uses the microphone (e.g., for oscilloscope or recording features) to make the request clearer to users.
```suggestion
<key>NSMicrophoneUsageDescription</key>
<string>This app uses the microphone to capture and analyze audio for oscilloscope and recording features.</string>
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| oscilloscopeStateProvider.isInBuiltMICSelected, | ||
| onChanged: (bool? value) async { | ||
| await Permission.microphone.request(); | ||
| if (Platform.isMacOS) { |
There was a problem hiding this comment.
issue (bug_risk): Guard Platform.isMacOS usage to avoid issues on web/unsupported platforms.
Using Platform from dart:io inside a widget will cause web builds (and any target without dart:io) to fail to compile. If this widget can appear in a web build, use a conditional approach (e.g. kIsWeb, conditional imports, or platform‑specific entry points) so Platform is never referenced on unsupported targets. Otherwise, ensure this code is isolated to desktop/mobile code paths that are not compiled for web.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Fixes #3181
Changes
I added MacOS exception for microphone. To do that I import a new library : flutter_macos_permissions, under licence GPL-3.0
I also added microphone permission in Configs file in macos -> Runner folder
I didn't find any other permission requests
Screenshots / Recordings
N/A
Checklist:
constants.dartor localization files instead of hard-coded values.dart formator the IDE formatter.flutter analyzeand tests run influtter test.Summary by Sourcery
Add macOS-specific handling for requesting microphone permissions when selecting the in-built microphone and declare the corresponding macOS permission usage metadata.
New Features:
Enhancements:
Build: