diff --git a/packages/local_auth/CHANGELOG.md b/packages/local_auth/CHANGELOG.md index 429e217cc167..f6c38489d8bb 100644 --- a/packages/local_auth/CHANGELOG.md +++ b/packages/local_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.4 + +* Add debug assertion that `localizedReason` in `LocalAuthentication.authenticateWithBiometrics` must not be empty. + ## 1.1.3 * Fix crashes due to threading issues in iOS implementation. diff --git a/packages/local_auth/lib/local_auth.dart b/packages/local_auth/lib/local_auth.dart index 3f332592a4dd..0b75a83d4029 100644 --- a/packages/local_auth/lib/local_auth.dart +++ b/packages/local_auth/lib/local_auth.dart @@ -59,7 +59,7 @@ class LocalAuthentication { /// /// [localizedReason] is the message to show to user while prompting them /// for authentication. This is typically along the lines of: 'Please scan - /// your finger to access MyApp.' + /// your finger to access MyApp.'. This must not be empty. /// /// [useErrorDialogs] = true means the system will attempt to handle user /// fixable issues encountered while authenticating. For instance, if @@ -100,7 +100,8 @@ class LocalAuthentication { bool sensitiveTransaction = true, bool biometricOnly = false, }) async { - assert(localizedReason != null); + assert(localizedReason.isNotEmpty); + final Map args = { 'localizedReason': localizedReason, 'useErrorDialogs': useErrorDialogs, diff --git a/packages/local_auth/pubspec.yaml b/packages/local_auth/pubspec.yaml index 5e2dbb4e6183..eccc2f812a89 100644 --- a/packages/local_auth/pubspec.yaml +++ b/packages/local_auth/pubspec.yaml @@ -2,7 +2,7 @@ name: local_auth description: Flutter plugin for Android and iOS devices to allow local authentication via fingerprint, touch ID, face ID, passcode, pin, or pattern. homepage: https://github.com/flutter/plugins/tree/master/packages/local_auth -version: 1.1.3 +version: 1.1.4 flutter: plugin: diff --git a/packages/local_auth/test/local_auth_test.dart b/packages/local_auth/test/local_auth_test.dart index d0a4dc8fc594..b24de8bd3c11 100644 --- a/packages/local_auth/test/local_auth_test.dart +++ b/packages/local_auth/test/local_auth_test.dart @@ -73,6 +73,17 @@ void main() { ); }); + test('authenticate with no localizedReason on iOS.', () async { + setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); + await expectLater( + localAuthentication.authenticate( + localizedReason: '', + biometricOnly: true, + ), + throwsAssertionError, + ); + }); + test('authenticate with no sensitive transaction.', () async { setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); await localAuthentication.authenticate(