fix(macos): address PR #31 review findings
- _showLocalNetworkDeniedSnackBar: wrap Process.run with unawaited() and .catchError() so a rejected future (e.g. macOS sandbox refuses fork, or 'open' is missing) cannot bubble into the Flutter zone as an unhandled exception. The synchronous try/catch was a no-op because Process.run only throws asynchronously. - macos_permissions_service_test.dart: mirror the triggerLocalNetworkPrompt error-handling test with one for checkLocalNetworkAccess. Probe-path failures (NWConnection probe cannot establish, or Swift side throws) must fall back to cached state without crashing the caller. Tests: 186 passed, 2 skipped. Dart analyze clean.
This commit is contained in:
@@ -648,11 +648,18 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
action: SnackBarAction(
|
||||
label: l10n.networkPermissionOpenSettings,
|
||||
onPressed: () {
|
||||
try {
|
||||
Process.run('open', [
|
||||
'x-apple.systempreferences:com.apple.preference.security?Privacy_LocalNetwork',
|
||||
]);
|
||||
} catch (_) {}
|
||||
// Fire-and-forget: don't block snackbar dismissal on the
|
||||
// child process. `Process.run` may throw synchronously
|
||||
// (e.g. exec ENOENT) or return a future that rejects
|
||||
// (e.g. macOS denies fork); both paths are swallowed
|
||||
// because the user can still open Settings manually.
|
||||
unawaited(
|
||||
Future<void>(() async {
|
||||
await Process.run('open', [
|
||||
'x-apple.systempreferences:com.apple.preference.security?Privacy_LocalNetwork',
|
||||
]);
|
||||
}).catchError((_) {}),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user