Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/view/widgets/channel_parameters_widget.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:pslab/l10n/app_localizations.dart';
import 'package:pslab/providers/locator.dart';
import 'package:pslab/providers/oscilloscope_state_provider.dart';
import 'package:flutter_macos_permissions/flutter_macos_permissions.dart';

import '../../theme/colors.dart';

Expand Down Expand Up @@ -249,7 +252,11 @@ class _ChannelParametersState extends State<ChannelParametersWidget> {
groupValue:
oscilloscopeStateProvider.isInBuiltMICSelected,
onChanged: (bool? value) async {
await Permission.microphone.request();
if (Platform.isMacOS) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

await FlutterMacosPermissions.requestMicrophone();
}else{
await Permission.microphone.request();
}
setState(
() {
if (value == null) {
Expand Down
2 changes: 2 additions & 0 deletions macos/Runner/DebugProfile.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions macos/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@
<string>NSApplication</string>
<key>NSLocationUsageDescription</key>
<string>This app needs access to location.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app uses the microphone to capture and analyze audio for oscilloscope and recording features.</string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions macos/Runner/Release.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
</dict>
</plist>
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ dependencies:
serial: ^0.0.7+1
web: ^1.1.1
mp_audio_stream: ^0.2.2
flutter_macos_permissions: ^2.0.8
dependency_overrides:
ffi: ^2.1.3

Expand Down
Loading