Skip to content

Commit

Permalink
update example, some documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
hpoul committed May 21, 2024
1 parent 9120b67 commit a498619
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 42 deletions.
19 changes: 19 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -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:
50 changes: 29 additions & 21 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -62,6 +62,8 @@ class MemoryAppender extends BaseLogAppender {
}

class MyApp extends StatefulWidget {
const MyApp({super.key});

@override
MyAppState createState() => MyAppState();
}
Expand Down Expand Up @@ -130,22 +132,26 @@ class MyAppState extends State<MyApp> {
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');
Expand Down Expand Up @@ -194,13 +200,13 @@ class MyAppState extends State<MyApp> {
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,
),
),
),
Expand Down Expand Up @@ -230,9 +236,11 @@ class MyAppState extends State<MyApp> {
}

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;
Expand Down
26 changes: 13 additions & 13 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 6 additions & 4 deletions lib/src/biometric_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -97,7 +99,7 @@ class StorageFileInitOptions {
? null
: Duration(seconds: authenticationValidityDurationSeconds)),
darwinTouchIDAuthenticationAllowableReuseDuration =
iosTouchIDAuthenticationAllowableReuseDuration ??
darwinTouchIDAuthenticationAllowableReuseDuration ??
(authenticationValidityDurationSeconds <= 0
? null
: Duration(seconds: authenticationValidityDurationSeconds));
Expand All @@ -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
Expand All @@ -146,8 +150,6 @@ class StorageFileInitOptions {
final bool darwinBiometricOnly;

Map<String, dynamic> toJson() => <String, dynamic>{
'authenticationValidityDurationSeconds':
authenticationValidityDurationSeconds,
'androidAuthenticationValidityDurationSeconds':
androidAuthenticationValidityDuration?.inSeconds,
'darwinTouchIDAuthenticationAllowableReuseDurationSeconds':
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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'

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
Expand Down

0 comments on commit a498619

Please sign in to comment.