Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I hide Flutter app contents when the app is in Background?

I'm developing an app that works with sensitive information.

One of the requirements is that when a user puts the app in background the content that the app is currently displaying has to be hidden, so if another person navigate through the apps in background he can't see the last screen where the user was.

Any ideas on how to do that?

I tried to show an overlay when the app moves to AppLifecycleState.paused, but it doesn't work for me, the app prints a message if I want but it can't update the UI.

like image 681
Jofre Avatar asked Sep 01 '25 10:09

Jofre


1 Answers

Edit Shameless plug: i did a library for doing just that as I also needed it:

https://pub.dev/packages/secure_application

Answear

Build is not called after paused, at least on Android.

For Android I used a flutter_windowmanager package (modified to still be able to build on IOS):

https://github.com/neckaros/flutter_windowmanager

When my app need securing I add the flag secure:

FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE)

And my app is now a black screen in the app switcher. You should still hide content your way for when the user get back to the app.

Otherwise you can go native: https://medium.com/@mehmetf_71205/securing-flutter-apps-ada13e806a69

like image 82
Arnaud JEZEQUEL Avatar answered Sep 02 '25 23:09

Arnaud JEZEQUEL