title: Flutter BLoC: managing the state of primary data types
body: <p>I am developing a mobile application using Flutter. I am new to Flutter. I am using BLoC for state management. I know that it is specially designed for management async execution. But also the purpose of BLoC is for state management. But I am a little bit confused and not quite sure how to handle the primary data types in BLoC.</p>
  
  <p>Let's imaging the I have a button and an image. The functionality would be that when the button is clicked, the visibility of the image will be toggled. Literally, we just need to use a boolean variable to manage the state of the image. This is how I would implement it.</p>
  
  <p>I have a bloc class called HomeBloc with the following implementation.</p>
  
  <pre><code>class HomeBloc {
    bool _isImageDisplayed = true;
    bool get isImageDisplayed =&gt; _isImageDisplayed;
    void set isImageDisplayed(bool displayed) {
       this._isImageDisplayed = displayed;
    }   
  
    //the rest of the code for other functionalities goes here
  }
  
  final homeBloc = HomeBloc();
  </code></pre>
  
  <p>Then in the HomePage widget, I update the state of the image like this inside the setState method when the button is clicked.</p>
  
  <pre><code> this.setState(() {        
       homeBloc.isImageDisplayed = false;
   });
  </code></pre>
  
  <p>My question is that "is it the standard way to manage primary data type in the BLoC in Flutter"? Is this the best practice? Do we need to use StreamBuilder? Do we even need to manage it inside the BLoC?</p>