screenLock function
Future<void>
screenLock({
- required BuildContext context,
- required String correctString,
- VoidCallback? onUnlocked,
- VoidCallback? onOpened,
- ValidationCallback? onValidate,
- VoidCallback? onCancelled,
- ValueChanged<
int> ? onError, - ValueChanged<
int> ? onMaxRetries, - int maxRetries = 0,
- Duration retryDelay = Duration.zero,
- Widget? title,
- ScreenLockConfig? screenLockConfig,
- SecretsConfig? secretsConfig,
- KeyPadConfig? keyPadConfig,
- DelayBuilderCallback? delayBuilder,
- Widget? customizedButtonChild,
- VoidCallback? customizedButtonTap,
- Widget? cancelButton,
- Widget? deleteButton,
- InputController? inputController,
- SecretsBuilderCallback? secretsBuilder,
- bool useBlur = true,
- bool useLandscape = true,
- bool canCancel = true,
Animated ScreenLock
correctString
: Input correct string (Required).onUnlocked
: Called if the value matches the correctString.onOpened
: For example, when you want to perform biometric authentication.onValidate
: Callback to validate input values filled indigits
.onCancelled
: Called when the user cancels the screen.onError
: Called if the value does not match the correctString.onMaxRetries
: Events that have reached the maximum number of attempts.maxRetries
:0
is unlimited. For example, if it is set to 1, didMaxRetries will be called on the first failure. Default0
.retryDelay
: Delay until we can retry. Duration.zero is no delay.title
: Change the title widget.screenLockConfig
: Configurations of ScreenLock.secretsConfig
: Configurations of Secrets.keyPadConfig
: Configuration ofKeyPad
.delayBuilder
: Specify the widget during input invalidation by retry delay.customizedButtonChild
: Child for bottom left side button.customizedButtonTap
: Tapped for left side lower button.footer
: Add a Widget to the footer.cancelButton
: Change the child widget for the delete button.deleteButton
: Change the child widget for the delete button.inputController
: Control inputs externally.secretsBuilder
: Custom secrets animation widget builder.useBlur
: Blur the background.useLandscape
: Use a landscape orientation. Defaulttrue
.canCancel
:true
is show cancel button.
Implementation
Future<void> screenLock({
required BuildContext context,
required String correctString,
VoidCallback? onUnlocked,
VoidCallback? onOpened,
ValidationCallback? onValidate,
VoidCallback? onCancelled,
ValueChanged<int>? onError,
ValueChanged<int>? onMaxRetries,
int maxRetries = 0,
Duration retryDelay = Duration.zero,
Widget? title,
ScreenLockConfig? screenLockConfig,
SecretsConfig? secretsConfig,
KeyPadConfig? keyPadConfig,
DelayBuilderCallback? delayBuilder,
Widget? customizedButtonChild,
VoidCallback? customizedButtonTap,
Widget? footer,
Widget? cancelButton,
Widget? deleteButton,
InputController? inputController,
SecretsBuilderCallback? secretsBuilder,
bool useBlur = true,
bool useLandscape = true,
bool canCancel = true,
}) async {
return Navigator.push<void>(
context,
PageRouteBuilder<void>(
opaque: false,
barrierColor: Colors.black.withOpacity(0.8),
pageBuilder: (context, animation, secondaryAnimation) => WillPopScope(
onWillPop: () async => canCancel && onCancelled == null,
child: ScreenLock(
correctString: correctString,
onUnlocked: onUnlocked ?? Navigator.of(context).pop,
onOpened: onOpened,
onValidate: onValidate,
onCancelled:
canCancel ? onCancelled ?? Navigator.of(context).pop : null,
onError: onError,
onMaxRetries: onMaxRetries,
maxRetries: maxRetries,
retryDelay: retryDelay,
title: title,
screenLockConfig: screenLockConfig,
secretsConfig: secretsConfig,
keyPadConfig: keyPadConfig,
delayBuilder: delayBuilder,
customizedButtonChild: customizedButtonChild,
customizedButtonTap: customizedButtonTap,
footer: footer,
cancelButton: cancelButton,
deleteButton: deleteButton,
inputController: inputController,
secretsBuilder: secretsBuilder,
useBlur: useBlur,
useLandscape: useLandscape,
),
),
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.0, 2.4),
end: Offset.zero,
).animate(animation),
child: SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(0.0, 2.4),
).animate(secondaryAnimation),
child: child,
),
),
),
);
}