Closed Reyth3 closed 1 week ago
@Reyth3
See the same example below. https://github.com/naoki0719/flutter_screen_lock/blob/f22571640a2b1f038db3cf185bdf18d263e7e7fb/example/lib/main.dart#L288-L298
ElevatedButton(
onPressed: () => screenLock(
context: context,
correctString: 'x' * 5,
onValidate: (value) async => await Future<bool>.delayed(
const Duration(milliseconds: 500),
() => value == '12345',
),
),
child: const Text('Callback validation'),
);
The correctString
should be a dummy string to set the length of the input.
For example, correctString: 'x' * 5
for 5 characters.
Next, define the necessary onValidate
.
In our example, the length is 5 characters, so this callback will be executed after 5 characters are entered.
The value
argument contains the input value, so you can validate it remotely or otherwise and return true
to close it.
Hi, I saw in the examples that with this package you have to provide
correctString
parameter. Can I skip it if I do not know the correct password ahead of time and will only know if it was correct or not after I get the response from the server?For my use case, the ideal behavior would be exactly like
screenLockCreate
, but without the password confirm, and with a success callback withvalue
param. Is this doable?Thank you!