v3 prevent screenshots

This commit is contained in:
2024-09-11 12:24:10 +02:00
parent 67958dae42
commit 438163a91e

View File

@@ -20,12 +20,8 @@ class MzanziInnovationHub extends StatefulWidget {
class _MzanziInnovationHubState extends State<MzanziInnovationHub> { class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
late ThemeMode _themeMode; late ThemeMode _themeMode;
late MyTheme theme; late MyTheme theme;
final _noScreenshot = NoScreenshot.instance;
void disableScreenshot() async { final _noScreenshot = NoScreenshot.instance;
bool result = await _noScreenshot.screenshotOff();
debugPrint('Screenshot Off: $result');
}
Color getPrimany() { Color getPrimany() {
return theme.primaryColor(); return theme.primaryColor();
@@ -54,10 +50,17 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
}); });
} }
void disableScreenshot() async {
await _noScreenshot.startScreenshotListening();
bool result = await _noScreenshot.screenshotOff();
debugPrint('Screenshot Off: $result');
}
void setPlatformSpecificPlugins() { void setPlatformSpecificPlugins() {
print("is PWA: ${theme.isPwa()}"); print("is PWA: ${theme.isPwa()}");
if (theme.isPwa()) { if (theme.isPwa()) {
disableScreenshot(); disableScreenshot();
//print(object)
} }
} }
@@ -65,13 +68,14 @@ class _MzanziInnovationHubState extends State<MzanziInnovationHub> {
void initState() { void initState() {
_themeMode = ThemeMode.dark; _themeMode = ThemeMode.dark;
theme = MyTheme(); theme = MyTheme();
setPlatformSpecificPlugins();
theme.mode = "Dark"; theme.mode = "Dark";
super.initState(); super.initState();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
setPlatformSpecificPlugins();
double width = MediaQuery.sizeOf(context).width; double width = MediaQuery.sizeOf(context).width;
theme.setScreenType(width); theme.setScreenType(width);
precacheImage(theme.loadingImage(), context); precacheImage(theme.loadingImage(), context);