I am trying to add 3 second video in splash screen in FLUTTER. so how to remove white screen before splash screen while launcher screen or any other suggestion are welcome for this.
Here’s what I’ve tried
class _MyAppState extends State<MyApp> {
late VideoPlayerController _controller;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.asset("assets/video.mp4");
_controller.addListener(() {
if (!_controller.value.isPlaying &&
_controller.value.position.inSeconds >=
_controller.value.duration.inSeconds) {
// completion
_controller.dispose();
Get.offAll(() => FirstScreen());
}
});
controller.initialize().then(() => setState(() {}));
_controller.play();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
return GetMaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: VideoPlayer(_controller),
),
);
}
}
2
Answers
You can’t entirely remove this screen. Only thing you can do is altering it in some way that it matches your video playing screen. Use https://pub.dev/packages/flutter_native_splash package and make it like that user doesn’t feel screen changing(make background same, etc)
First create
styles.xml
file insideandroid/app/src/main/res/values
.styles.xml
Now add your splash screen inside
res/drawable
folder.AndroidManifest.xml
Inside
activity
tag createmeta-data
like this,