title: events management flutter bloc pattern
body: <p>everyone. I am new in Flutter and BLoC pattern.</p>
  <p>I needed to implement contact page so I created event GetContacts and passed it into context.read().add() after that I called this event into initState() of contacts screen.</p>
  <p>Here my event:</p>
  <pre><code>
  abstract class ContactEvent extends Equatable {
    const ContactEvent([List props = const []]) : super();
  }
  
  class GetContacts extends ContactEvent {
  
    const GetContacts() : super();
  
    @override
    List&lt;Object&gt; get props =&gt; [];
  } 
  </code></pre>
  <p>Here is my bloc:</p>
  <pre><code>class ContactsBloc extends Bloc&lt;ContactEvent, ContactsState&gt; {
    final ContactsRepo contactsRepo;
    ContactsBloc({required this.contactsRepo}) : super(ContactInitial());
  
    @override
    Stream&lt;ContactsState&gt; mapEventToState(ContactEvent event,) async* {
      yield ContactsLoading();
      //
      // if (event is UpdatePhoto) {
      //   yield PhotoLoading();
      //
      //   print(&quot;LOADING STARTED&quot;);
      //
      //   final photo = await contactsRepo.updatePhoto(event.identifier, event.photo);
      //   print(&quot;LOADING FINISHED&quot;);
      //
      //   yield PhotoLoaded(photo: photo);
      // }
      if (event is GetContacts) {
        print(&quot;get contacts photoBloc&quot;);
        try {
  
          final contacts = await contactsRepo.getContacts();
          yield ContactsLoaded(contacts);
        } on AccessException {
          yield ContactsError();
        }
      }
    }
  } 
  </code></pre>
  <p>That works right and contacts page renders contacts as it is supposed.</p>
  <p>[contacts screen][1]
  [1]: https://i.stack.imgur.com/Gx3JA.png</p>
  <p>But then I decided to implement new feature: when user clicks on any contact he is offered to change its photo.
  If I understand BLoC pattern correctly then if I want to change my state I need to create new event. Then I created new action UpdatePhoto and passed it into the same Bloc as it shown at 2nd part of code (in comments). Exactly there I encounter a misunderstanding of architecture expansion. This action is not supposed to return ContactsLoaded state so when I tried to catch this into my another bloc builder it broke my previous bloc builder that caught GetContact event.</p>
  <p>ContactState:</p>
  <pre><code>abstract class ContactsState extends Equatable {
    const ContactsState([List props = const []]) : super();
  }
  
  
  // class PhotoLoading extends PhotoState {
  //   @override
  //   List&lt;Object?&gt; get props =&gt; [];
  // }
  //
  // class PhotoLoaded extends PhotoState {
  //   final Uint8List photo;
  //   const PhotoLoaded({required this.photo});
  //   @override
  //   List&lt;Object?&gt; get props =&gt; [photo];
  // }
  
  class ContactInitial extends ContactsState {
    @override
    List&lt;Object&gt; get props =&gt; [];
  }
  
  class ContactsLoading extends ContactsState {
    @override
    List&lt;Object&gt; get props =&gt; [];
  }
  
  class ContactsLoaded extends ContactsState {
    final List&lt;MyContact&gt; contacts;
    ContactsLoaded(this.contacts) : super([contacts]);
  
    @override
    List&lt;Object&gt; get props =&gt; [contacts];
  }
  
  class ContactsError extends ContactsState {
    @override
    List&lt;Object?&gt; get props =&gt; [];
  }
  </code></pre>
  <p>Question: If I want to create new event (for example UpdatePhoto) which is not supposed to return the state that I caught before at the same bloc then I need to create new bloc for that purpose and cover my screen by multiProvider?</p>