skip to Main Content

I have a bool called isSubmited. Default value is false. I want to change the value when user click on a button but the fact is how can I do it without the setState method in flutter.
I just want to change the value not the user interface. I just want change the bool value nothing else. But not the app state itself!

3

Answers


  1. just change the value without wrapping it with setState.
    isSubmitted = false;

    Login or Signup to reply.
  2. you can use hive cache so set/get your boolean value ( or any other value bool, String, anytime in your app without changing user interface

    Example :

    var box = Hive.box(‘myBox’);

    box.put(‘isSubmited’, true);

    bool isSubmited = box.get(‘isSubmited’);

    Login or Signup to reply.
  3. you can update the bool value without setState method.
    if you are not updating the state on the app based on "isSubmited" value then you don’t need to setState. just assign it like this

    onPressed:(){
    isSubmitted=true; 
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search