Here You can check the document for setstate, and after setstate if you use bool to change then UI won't change but value of variable get changed.