diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..0ba1255 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,19 @@ +include: package:flutter_lints/flutter.yaml + +analyzer: + errors: + # treat missing required parameters as a warning (not a hint) + missing_required_param: warning + # treat missing returns as a warning (not a hint) + missing_return: warning + # allow having TODOs in the code + todo: ignore + exclude: + - lib/generated_plugin_registrant.dart + - example/lib/generated_plugin_registrant.dart + language: + strict-casts: true + strict-raw-types: true + +linter: + rules: diff --git a/example/lib/main.dart b/example/lib/main.dart index 46459c3..15ee52a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,7 +15,7 @@ void main() { PrintAppender().attachToLogger(Logger.root); logMessages.attachToLogger(Logger.root); _logger.fine('Application launched. (v2)'); - runApp(MyApp()); + runApp(const MyApp()); } class StringBufferWrapper with ChangeNotifier { @@ -62,6 +62,8 @@ class MemoryAppender extends BaseLogAppender { } class MyApp extends StatefulWidget { + const MyApp({super.key}); + @override MyAppState createState() => MyAppState(); } @@ -130,22 +132,26 @@ class MyAppState extends State { authenticationRequired: false, )); if (supportsAuthenticated) { - _customPrompt = await BiometricStorage().getStorage( - '${baseName}_customPrompt', - options: StorageFileInitOptions( - authenticationValidityDurationSeconds: 5), - promptInfo: const PromptInfo( - iosPromptInfo: IosPromptInfo( - saveTitle: 'Custom save title', - accessTitle: 'Custom access title.', - ), - androidPromptInfo: AndroidPromptInfo( - title: 'Custom title', - subtitle: 'Custom subtitle', - description: 'Custom description', - negativeButton: 'Nope!', - ), - )); + _customPrompt = await BiometricStorage() + .getStorage('${baseName}_customPrompt', + options: StorageFileInitOptions( + androidAuthenticationValidityDuration: + const Duration(seconds: 5), + darwinTouchIDAuthenticationAllowableReuseDuration: + const Duration(seconds: 5), + ), + promptInfo: const PromptInfo( + iosPromptInfo: IosPromptInfo( + saveTitle: 'Custom save title', + accessTitle: 'Custom access title.', + ), + androidPromptInfo: AndroidPromptInfo( + title: 'Custom title', + subtitle: 'Custom subtitle', + description: 'Custom description', + negativeButton: 'Nope!', + ), + )); } setState(() {}); _logger.info('initiailzed $baseName'); @@ -194,13 +200,13 @@ class MyAppState extends State { color: Colors.white, constraints: const BoxConstraints.expand(), child: SingleChildScrollView( + reverse: true, child: Container( padding: const EdgeInsets.all(16), child: Text( logMessages.log.toString(), ), ), - reverse: true, ), ), ), @@ -230,9 +236,11 @@ class MyAppState extends State { } class StorageActions extends StatelessWidget { - const StorageActions( - {Key? key, required this.storageFile, required this.writeController}) - : super(key: key); + const StorageActions({ + super.key, + required this.storageFile, + required this.writeController, + }); final BiometricStorageFile storageFile; final TextEditingController writeController; diff --git a/example/pubspec.lock b/example/pubspec.lock index 8472261..ac3fa63 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -52,10 +52,10 @@ packages: dependency: transitive description: name: dio - sha256: "797e1e341c3dd2f69f2dad42564a6feff3bfb87187d05abb93b9609e6f1645c3" + sha256: "11e40df547d418cc0c4900a9318b26304e665da6fa4755399a9ff9efd09034b5" url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.4.3+1" fake_async: dependency: transitive description: @@ -68,10 +68,10 @@ packages: dependency: transitive description: name: ffi - sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" flutter: dependency: "direct main" description: flutter @@ -81,10 +81,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 + sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "4.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -139,10 +139,10 @@ packages: dependency: transitive description: name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "4.0.0" logging: dependency: "direct main" description: @@ -155,10 +155,10 @@ packages: dependency: "direct main" description: name: logging_appenders - sha256: "1fb8a008c04246f4677a0d034d69779a5975e56e02573a5162240239b247e239" + sha256: cc16fd4ecf92ae8b45294ad01849468475b65c4aadac57c2ed3e6cc3f91b557c url: "https://pub.dev" source: hosted - version: "1.2.0+1" + version: "1.3.0" matcher: dependency: transitive description: @@ -280,10 +280,10 @@ packages: dependency: transitive description: name: win32 - sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" + sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4 url: "https://pub.dev" source: hosted - version: "5.2.0" + version: "5.5.1" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.4.0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b9578db..0229490 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.1 + flutter_lints: ^4.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 1a81581..82cc80b 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -12,7 +12,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that platform version is retrieved. expect( diff --git a/lib/src/biometric_storage.dart b/lib/src/biometric_storage.dart index f28af28..f07bf0c 100644 --- a/lib/src/biometric_storage.dart +++ b/lib/src/biometric_storage.dart @@ -85,8 +85,10 @@ class AuthException implements Exception { class StorageFileInitOptions { StorageFileInitOptions({ Duration? androidAuthenticationValidityDuration, - Duration? iosTouchIDAuthenticationAllowableReuseDuration, + Duration? darwinTouchIDAuthenticationAllowableReuseDuration, this.darwinTouchIDAuthenticationForceReuseContextDuration, + @Deprecated( + 'use use androidAuthenticationValidityDuration, iosTouchIDAuthenticationAllowableReuseDuration or iosTouchIDAuthenticationForceReuseContextDuration instead') this.authenticationValidityDurationSeconds = -1, this.authenticationRequired = true, this.androidBiometricOnly = true, @@ -97,7 +99,7 @@ class StorageFileInitOptions { ? null : Duration(seconds: authenticationValidityDurationSeconds)), darwinTouchIDAuthenticationAllowableReuseDuration = - iosTouchIDAuthenticationAllowableReuseDuration ?? + darwinTouchIDAuthenticationAllowableReuseDuration ?? (authenticationValidityDurationSeconds <= 0 ? null : Duration(seconds: authenticationValidityDurationSeconds)); @@ -123,6 +125,8 @@ class StorageFileInitOptions { /// see https://github.com/authpass/biometric_storage/pull/73 /// This is pretty much undocumented behavior, but works similar to /// `androidAuthenticationValidityDuration`. + /// + /// See also [darwinTouchIDAuthenticationAllowableReuseDuration] final Duration? darwinTouchIDAuthenticationForceReuseContextDuration; /// Whether an authentication is required. if this is @@ -146,8 +150,6 @@ class StorageFileInitOptions { final bool darwinBiometricOnly; Map toJson() => { - 'authenticationValidityDurationSeconds': - authenticationValidityDurationSeconds, 'androidAuthenticationValidityDurationSeconds': androidAuthenticationValidityDuration?.inSeconds, 'darwinTouchIDAuthenticationAllowableReuseDurationSeconds': diff --git a/pubspec.yaml b/pubspec.yaml index 1e8f409..1a10cb1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: flutter_web_plugins: sdk: flutter logging: ">=1.0.0 <2.0.0" - plugin_platform_interface: ^2.0.0 + plugin_platform_interface: ">=2.0.0 <3.0.0" ffi: '>=1.0.0 <3.0.0' win32: '>=2.0.0 <6.0.0' @@ -23,7 +23,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.1 + flutter_lints: ^4.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec