From 2912a97ee05cdef70aa4d330917f7e2a023b97c8 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 26 Mar 2024 09:17:26 +0100 Subject: [PATCH] Resolve unhandled exception on iOS --- permission_handler_platform_interface/CHANGELOG.md | 4 ++++ .../method_channel/method_channel_permission_handler.dart | 5 +++++ permission_handler_platform_interface/pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/permission_handler_platform_interface/CHANGELOG.md b/permission_handler_platform_interface/CHANGELOG.md index e5204299f..092a80711 100644 --- a/permission_handler_platform_interface/CHANGELOG.md +++ b/permission_handler_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.2.1 + +* Resolves an error that occurred when calling the `shouldShowRequestPermissionRationale` on iOS. + ## 4.2.0 * Adds a new permission `Permission.backgroundRefresh` to check the background refresh permission status on iOS & macOS platforms. This is a no-op on all other platforms. diff --git a/permission_handler_platform_interface/lib/src/method_channel/method_channel_permission_handler.dart b/permission_handler_platform_interface/lib/src/method_channel/method_channel_permission_handler.dart index 2f9cc0beb..5f03e3e7a 100644 --- a/permission_handler_platform_interface/lib/src/method_channel/method_channel_permission_handler.dart +++ b/permission_handler_platform_interface/lib/src/method_channel/method_channel_permission_handler.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import '../../permission_handler_platform_interface.dart'; @@ -88,6 +89,10 @@ class MethodChannelPermissionHandler extends PermissionHandlerPlatform { @override Future shouldShowRequestPermissionRationale( Permission permission) async { + if (defaultTargetPlatform != TargetPlatform.android) { + return false; + } + final shouldShowRationale = await _methodChannel.invokeMethod( 'shouldShowRequestPermissionRationale', permission.value); diff --git a/permission_handler_platform_interface/pubspec.yaml b/permission_handler_platform_interface/pubspec.yaml index a638b4dfb..14957a1cd 100644 --- a/permission_handler_platform_interface/pubspec.yaml +++ b/permission_handler_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin. homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 4.2.0 +version: 4.2.1 dependencies: flutter: