no_screenshot 0.0.1+1 no_screenshot: ^0.0.1+1 copied to clipboard
Flutter plugin to enable, disable or toggle screenshot support in your application.
no_screenshot #
Flutter plugin to enable, disable or toggle screenshot support in your application.
Getting Started #
If you want to prevent user from taking screenshot or recording of your app. You can turn off the screenshot support from the root didChangeAppLifecycleState
method.
class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
final _noScreenshot = NoScreenshot();
AppLifecycleState? _notification;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
case AppLifecycleState.resumed, :
print("app in resumed");
if(app_secure) _noScreenshot.screenshotOff();
break;
case AppLifecycleState.inactive:
print("app in inactive");
if(app_secure) _noScreenshot.screenshotOff();
break;
case AppLifecycleState.paused:
print("app in paused");
if(app_secure) _noScreenshot.screenshotOff();
break;
case AppLifecycleState.detached:
print("app in detached");
break;
}
}
@override
void initState() {
super.initState();
WidgetsBinding.instance?.addObserver(this);
...
}
@override
void dispose() {
WidgetsBinding.instance?.removeObserver(this);
super.dispose();
}