Is there any way to detect if screen is getting captured for my app in flutter? I want to turn my screen black if any app/system is recoding screen while my app is active.
Is it possible in flutter?
try this plugin flutter_windowmanager
to prevent screen shot and video record
in main file :
disableCapure() async {
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
}
then call that method after runApp
void main(){
runApp(...);
disableCapure();
}
although for ios you have to know native code maybe it not work pretty for ios
Related
I've trying to run my app in debug mode, but my app was laggy and didn't get 60fps.
Then i'm trying to run my app in release mode with
flutter run --release
And i got 60 fps, but i got my image in launch_background.xml as Splash Screen disappearing too fast.
How to increase the display time, maybe 3 until 5 seconds, like in debug mode ?
Do me a favor please...
You can't calculate the exact time, It depends on the hardware and platform the application is running on it.
Flutter takes some time to render and this time is different for different devices.
But you can put a delay just before the runApp function, if you need to show the splash screen longer than flutter rendering time. like this:
void main() async {//make your main function async
//put delay here with await:
await Future.delayed(Duration(seconds: 3));
runApp(MyApp());
//total splash time = your delay + the time that Flutter needs to render
}
I am writing a landscape flutter application that uses the camera plugin.
To make my app landscape, I have the following lines in my main:
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft]);
This does not prevent from receiving a landscape image from the camera stream so, after initializing the camera controller, I have the line
_controller?.lockCaptureOrientation(DeviceOrientation.landscapeRight);
With this line, the camera gives only landscape images, but now the app will not work properly in landscapeLeft. Is there a way to enforce the capture orientation to be either landscapeRight
or landscapeLeft?
Try to specify lockCaptureOrientation() after inialization and restart the camera screen.
await cameraController?.initialize();
await cameraController?.lockCaptureOrientation();
I am using the flutter_native_splash plugin to show a splash screen for my flutter application. I need to show the splash screen for Android and iOS, but not for the web app. How can I disable the splash screen for the web app.
Thanks in advance!
Set
web: false
in your config.
Edit: note that you can avoid using a splash screen on web, but the browser will display a white screen while the Flutter framework loads, so without a splash screen, your users will experience a blank screen for some period of time depend on the speed of their connection.
You can check what platform you're on kIsWeb:
import 'package:flutter/foundation.dart' show kIsWeb;
if (!kIsWeb) {
//Dont show splash
}else{
//Show splash
}
In my flutter app I'm playing an animation. And I want to start the playback only after all the widgets on the page have loaded. Essencially I'm looking for the JS equivalnat of window.onload in flutter. Right now the animation starts as soon as it can and the result it that when the app lunches I see a white screen while the app is loading for a few seconds and when the app is finally loaded the animation is already half way through the playback.
Is there a signal or event in flutter that will let me know that the app has loaded?
In a widget you can use
WidgetsBinding.instance.addPostFrameCallback((_){
//stuff
})
If you put this in your initState the callback will be called after the first frame is rendered, if that's what you need.
I am using the Flutter Video Chewie package to show quite short videos about 4-5 minutes in length. However when playing the videos, when the phones screen saver timeout is reached the screen closes and stops the video.
I checked in the Chewie parameters and set the: AllowedScreenSleep parameter to false, however it still closes.
Is there a way in Chewie to make sure that this doesn't happen?
Many thanks any help with this as always appreciated.
Use this dependency and write this line when your video start playing Wakelock.enable() and when stop playing *Waklock.disable():
if you use this thing then your screen saver not get in picture while the video is playing :)
import 'package:wakelock/wakelock.dart';
// ...
// The following line will enable the Android and iOS wakelock.
Wakelock.enable();
// The next line disables the wakelock again.
Wakelock.disable();