Flutter: Test that a specific exception is thrown : <p>in short, <code>throwsA(anything)</code> does not suffice for me while unit testing in dart. How to I test for a <strong>specific error message or type</strong>?</p>

<p>Here is the error I would like to catch:</p>

<pre><code>class MyCustErr implements Exception {
  String term;

  String errMsg() =&gt; 'You have already added a container with the id 
  $term. Duplicates are not allowed';

  MyCustErr({this.term});
}
</code></pre>

<p>here is the current assertion that passes, but would like to check for the error type above:</p>

<p><code>expect(() =&gt; operations.lookupOrderDetails(), throwsA(anything));</code></p>

<p>This is what I want to do:</p>

<p><code>expect(() =&gt; operations.lookupOrderDetails(), throwsA(MyCustErr));</code></p>
