flick-video-player
flick-video-player copied to clipboard
SetState() is not working in fullscreen video
I am adding watermark at random position of video. It is working proper in normal screen view. but when I switch to full screen mode the position of watermark is not updating.
Here's my code to achieve this :
void timer(isFullScreen) async { if (!courseController.isTimerActive) { Timer.periodic(_duration, (timer) { if (mounted) {
// check if the widget is still mounted
setState(() {
print('isFullScreen::->$isFullScreen');
if(isFullScreen){
var top = (Random().nextDouble() * (MediaQuery.of(context).size.height - 550.sp)).toString();
if(top.contains("-")){
top = top.substring(0,1);
}
var left = (Random().nextDouble() * (MediaQuery.of(context).size.width - 100.sp)).toString();
if(left.contains("-")){
left = left.substring(0,1);
}
courseController.topPosition.value = double.parse(top);
courseController.leftPosition.value = double.parse(left);
} else {
courseController.topPosition.value = Random().nextDouble() * (MediaQuery.of(context).size.height - 550.sp);
courseController.leftPosition.value = Random().nextDouble() * (MediaQuery.of(context).size.width - 100.sp);
}
});
}
});
courseController.isTimerActive = true;
}
}
timer(isFullScreen);
Positioned( top: courseController.topPosition.value, left: courseController.leftPosition.value, child: Container( color: Colors.black26, child: Text( courseController.securityCode.value, style: Styles.textFontOpenSansSemiBold( size: 12.sp, color: Styles.blackColor) ), ), ),