Above are blocks for screen 1.
whenever I press the button to change the screen from 1 to 2 and again come back to screen 1 the time recorded previously changes to the current time
what I want is for it to hold the time value until value on Firebase doesn't change.
When you changes screen and go back your variable initializes to empty string . Only when data changes on firebase 2 or 4 time will update again.
If you want to save the value between 2 data changes on firebase or when you change screen you have to use a persistent database like tinyDb.
I have real-time values that come from device1 and 2 via ESP32 in Firebase from there I display those value in my mit-aap but the problem is that when I change my screen 1 to 2 and again come back to screen 1 the clock triggers and changes the time even if there is no change in firebase. I applied the logic that if the value in Firebase changes then only it should trigger the clock.
The value go to empty or changes to a new value ?
In the first case when you come back from screen 2 variable initialize to empty, in the second case there is some changes on firebase that activates the data changes block of firebase .
Something changes in firebase, try to modify the if control using the most specific tag or value for the control .
You can set a notifier in your code to verify when your data changes starts. Could be a trick to know how firebase works and find the error