Flutter App Lock - Security

Custom Code

Hello,

I am building an application where the security is key.

In order to add a local security layer on my app, I would like to add the biometric authentication when the app starts and when the app is resumed (after being in the background).

Currently, I am doing this in the following way:

  • I added a custom action in my main.dart file, which add a lifecycle observer

  • When the app start, I trigger the biometric authentication and I set the lifecycle observer

  • When the app is "resumed" in the lifecycle, I trigger the biometric authentication

I am not sure about the security of this flow.

I found this flutter pub: https://pub.dev/packages/flutter_app_lock

It seems to be more secure about the app start given the whole app seems to be wrapped in an AppLock widget, so it conditionally loads the rest of the app according to the auth result.
About the app resume, it seems to do the same thing I have done.

How to implement this pub? According to the doc, the BuildContext seems to be required to override the native behavior.

Unless I am wrong, we cannot use the BuildContext in a custom action that we would add to the main.dart file.

In a custom action, I do not know how to override the class MyApp.

Maybe I can do this with a custom Widget?

According to you, the pub is more robust than my current flow?

Do you have an idea to implement it?

Find attached my current main.dart file in FlutterFlow, as well as the usage example of flutter_app_lock pub .

What have you tried so far?

Currently, I am doing this in the following way:

  • I added a custom action in my main.dart file, which add a lifecycle observer

  • When the app start, I trigger the biometric authentication and I set the lifecycle observer

  • When the app is "resumed" in the lifecycle, I trigger the biometric authentication

Did you check FlutterFlow's Documentation for this topic?
Yes
2
1 reply