title: Flutter BLoC/Cubit STATE class best practices
body: <p>I'm new to using Bloc and Cubit so I'm trying to figure out some best practices specifically with the State component. I have a simple Todos app where the Todos can be in multiple different states:</p>
  <pre><code>part of 'todos_cubit.dart';
  
  abstract class TodosState extends Equatable {
    const TodosState();
  
    @override
    List&lt;Object&gt; get props =&gt; [];
  }
  
  class TodosLoading extends TodosState {}
  
  class TodosLoaded extends TodosState {
    final List&lt;Todo&gt; todos;
  
    TodosLoaded(this.todos);
  
    @override
    bool operator ==(Object other) {
      if (identical(this, other)) return true;
  
      return other is TodosLoaded &amp;&amp; listEquals(other.todos, todos);
    }
  
    @override
    int get hashCode =&gt; todos.hashCode;
  }
  
  class TodosEmpty extends TodosState {}
  
  class TodosError extends TodosState {
    final String error;
  
    TodosError(this.error);
  
    @override
    bool operator ==(Object other) {
      if (identical(this, other)) return true;
  
      return other is TodosError &amp;&amp; other.error == error;
    }
  
    @override
    int get hashCode =&gt; error.hashCode;
  }
  </code></pre>
  <p>My question is, should I keep the <code>List&lt;Todo&gt; todos</code> in the <code>TodosLoaded</code> subclass or should it be moved to the base class? My thoughts are that by moving it to the base class, it would make my <code>TodosEmpty</code> state redundant because I could simple check to see if the list of todos is empty in the UI. If this is the case, should I also move the <code>String error</code> to the base class?</p>
  <p>Im sure there are pros and cons to each approach, just hoping to bounce ideas off anyone with more experience with Bloc.</p>