title: Flutter: Testing for exceptions in widget tests
body: <p>How do I go about making sure the ui (widget) throws an exception during widget testing in Flutter. Here is my code that does not work:</p>
  
  <pre><code>expect(
    () =&gt; tester.tap(find.byIcon(Icons.send)),
    throwsA(const TypeMatcher&lt;UnrecognizedTermException&gt;()),
  );
  </code></pre>
  
  <p>It fails with the following error</p>
  
  <pre><code>...
  Expected: throws &lt;Instance of 'TypeMatcher&lt;UnrecognizedTermException&gt;'&gt;
    Actual: &lt;Closure: () =&gt; Future&lt;void&gt;&gt;
     Which: returned a Future that emitted &lt;null&gt;
  </code></pre>
  
  <p>OR......should I be testing how the UI <strong>handles</strong> an exception by looking for error messages, etc??</p>