title: Getting Option<Either<T,T>> unpacked in Flutter
body: <p>In my bloc state I have this:</p>
  
  <pre class="lang-dart prettyprint-override"><code>Option&lt;Either&lt;T, Stream&lt;T&gt;&gt;&gt; optionFailureOrStream,
  </code></pre>
  
  <p>It' can be empty (<code>Option</code>) or have an <code>error</code> or a <code>stream</code>.</p>
  
  <p>In my <code>bloc</code> I yielding this with <code>optionOf</code> like this:</p>
  
  <pre class="lang-dart prettyprint-override"><code> yield state.copyWith(optionFailureOrStream: optionOf(failureOrStream));
  </code></pre>
  
  <p>Now in my Widget I want to know if it has a value and if it has a value, I want to fold them to return two different screens:</p>
  
  <pre class="lang-dart prettyprint-override"><code> if (state.optionFailureOrStream.isSome()) {
      final optionFailureOrStream = state.optionFailureOrStream;
  
      optionFailureOrStream.map((a) =&gt; a.fold(
          (failure) =&gt; FailureWidget(failure: failure),
          (stream) =&gt; buildSaved(stream, context)));
  }
  </code></pre>
  
  <p>But somehow I can't get rid of the <code>Option&lt;T&gt;</code> type. It complains about the wrong type. </p>
  
  <pre><code>The return type 'Option&lt;Widget&gt;' isn't a 'Widget', as required by the closure's context.dart(return_of_invalid_type_from_closure)
  </code></pre>
  
  <p>I assume there is a really easy way to do this. I am having a real hard time finding any dart/flutter related manuals and the source code of <code>dartz</code> isn't that self-explaining, if you are new to these concepts.</p>