How to require user to set phone password in app by Flutter?
I'm working on an app in 开发者_开发知识库Flutter that needs to require users to set a PIN/Password/FaceID/... on their phone (any authenticate method) if there is currently none, for security purposes for the app. I'm currently looking for a Flutter library or a method that can help me with this, but still can't find it.
My expectation is simple, when the user opens the app, it will check if the current device has any local authenticate method in use. If none, the app will show a dialog to inform the user and take him to the settings.
I appreciate all your answers! Pls help!
You can use the local_auth to check the device is set any type of security or NOT with this function:
final List availableBiometrics = await auth.getAvailableBiometrics();
If the result is empty, it mean you have not set any type of security in the device.
One way to require a user to set a phone password in an app built with Flutter is to use the local_auth package. This package provides an easy-to-use API that allows you to authenticate the user with their device's security features such as fingerprint, face ID, or passcode. You can use it to prompt the user to set a new password or confirm their existing password before proceeding with an action in your app.
精彩评论