Problem night mode

I want to put a button that when pressed activates the theme of night colors and when I give it again the day mode is activated and this is registered in the tiny so that the choice is saved at the time of starting the application


the problem is that it always starts me in day mode and the button does not work

When you select mode, save in TinyDB a tag named MODO. In that tag save DIA or NOCHE depending on the current value (If MODO = DIA then MODO = NOCHE else MODO = DIA).

When the app initializes, ask if MODO = DIA then call MODODIA procedure, else call MODONOCTURNO.

Cuando seleccionas el modo, guarda en TinyDB el tag MODO. En ese tag guarda DIA o NOCHE dependiendo del valor actual (Si MODO = DIA entonces MODO = NOCHE sino MODO = DIA).

Cuando el app inicia pregunta si MODO = DIA, llama a MODODIA sino llama a MODONOCTURNO.

I got the button to work and it changed me from night mode to day mode but the value should not be saved because if I quit the application or open another tab when I return, it returns to the beginning

You are not doing what I told you to do. You are setting night mode to true or false and you are mixing everything later because it gets confusing.
Instead of using TRUE or FALSE for night mode, just create a tag called MODE and in it store NIGHT if the user chose night mode or DAY if they chose day mode. That’s it.
Then everytime you need to set the mode, just read what it says there and that’s it.