l am using biometric to auth users in my app,
Is their a way in flutter to detect if new finger have being added in phone ??
This depends on the platform and how exactly you want to do this.
On Android, when you create a key you can specify that it is invalidated if additional fingerprints are enrolled using KeyGenParameterSpec.Builder
's setInvalidatedByBiometricEnrollment
function. However, there is a caveat with this - it only works with keys that require active authentication, and the only way to find out that a key has been invalidated is to try authenticating it... which would throw a KeyPermanentlyInvalidatedException
if this were the case, but would probably open the authentication dialog if it is still valid which might not be what you want in terms of user experience.
On iOS, it's a little more straightforward as you can check the domain state
let context = LAContext()
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil {
if let newDomainState = context.evaluatedPolicyDomainState {
if newDomainState.base64EncodedString() != oldDomainStateString {
// doesn't match so have to update oldDomainStateString (wherever that is saved)
// and do whatever else.
} else {
// domains still match, fingerprint still the same.
}
} else {
// can't get the policy for some reason. Hopefully shouldn't happen
// since we're checking canEvaluatePolicy
}
}
However, there's another issue - neither of those APIs are exposed directly through any plugin that I'm aware of anyways, so you're going to have to write the native code yourself. Honestly this probably isn't the worst thing anyways since you should have a pretty good understanding of this stuff or do a very good job of reading any 3rd-party libraries you use for it, but it does mean that you'll have to have a good understanding of flutter's platform channels, as well as both iOS/swift and Android/kotlin code & security APIS to be able to implement it.