Leaving and return to page causes function to run at an increasing number of times

Hello,
I am having a problem that I can not figure out at all. I have a function that reads a value from the Firestore database and then determines whether a switch should be on or off. This allows me to have accurate points for my user at any given time in my app. However, whenever I leave that view and then return, that function will run twice for apparently no reason. If I do it again, the function will run 4 times, then 8, and so on. Do you have any idea what could be causing this to happen?


I would have added more pictures, but it would not allow me to.

It might be possible that its adding a snapshot listener everytime you run the function