Skip to content

Commit bc684e0

Browse files
enricobenedosfotiDim
authored andcommitted
[local_auth] Fix iOS crash when no localizedReason (flutter#3780)
1 parent 938e6aa commit bc684e0

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

packages/local_auth/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.4
2+
3+
* Add debug assertion that `localizedReason` in `LocalAuthentication.authenticateWithBiometrics` must not be empty.
4+
15
## 1.1.3
26

37
* Fix crashes due to threading issues in iOS implementation.

packages/local_auth/lib/local_auth.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class LocalAuthentication {
5959
///
6060
/// [localizedReason] is the message to show to user while prompting them
6161
/// for authentication. This is typically along the lines of: 'Please scan
62-
/// your finger to access MyApp.'
62+
/// your finger to access MyApp.'. This must not be empty.
6363
///
6464
/// [useErrorDialogs] = true means the system will attempt to handle user
6565
/// fixable issues encountered while authenticating. For instance, if
@@ -100,7 +100,8 @@ class LocalAuthentication {
100100
bool sensitiveTransaction = true,
101101
bool biometricOnly = false,
102102
}) async {
103-
assert(localizedReason != null);
103+
assert(localizedReason.isNotEmpty);
104+
104105
final Map<String, Object> args = <String, Object>{
105106
'localizedReason': localizedReason,
106107
'useErrorDialogs': useErrorDialogs,

packages/local_auth/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: local_auth
22
description: Flutter plugin for Android and iOS devices to allow local
33
authentication via fingerprint, touch ID, face ID, passcode, pin, or pattern.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/local_auth
5-
version: 1.1.3
5+
version: 1.1.4
66

77
flutter:
88
plugin:

packages/local_auth/test/local_auth_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ void main() {
7373
);
7474
});
7575

76+
test('authenticate with no localizedReason on iOS.', () async {
77+
setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios'));
78+
await expectLater(
79+
localAuthentication.authenticate(
80+
localizedReason: '',
81+
biometricOnly: true,
82+
),
83+
throwsAssertionError,
84+
);
85+
});
86+
7687
test('authenticate with no sensitive transaction.', () async {
7788
setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android'));
7889
await localAuthentication.authenticate(

0 commit comments

Comments
 (0)