I have a stopwatch in Dart that counts seconds. I also have a youtube iframe above it. (flutter framework) When the YouTube iframe is run in full screen the stopwatch stops even though it is contained in a Stateful widget. When I get out of full screen mode in Youtube, the stopwatch does preserve the state in the sense it shows the time it stopped but I want it to run in the background. I know that Dart is not multithreaded and even if it was, there's no guarantee that Android wont kill it off. I saw some solutions online where the SharedPreferences are used to store the time during initState and that time is added to a modified StopWatch. However this solution is not working for me because the initState doesn't get called when the video is changed from full screen. This might be because the widget screen is not rebuilt? Is there some other event I can watch/override? Is there something I can do besides storing the time as key-value and retrieving it/ deleting it from SharedPreferences?
I tried to use SharedPreferences but it didnt work because initState didnt get called