title: Missing case clause error in dart switch case with enums
body: <p>I wrote this simple switch case for an enum:</p>
  
  <pre><code>enum Operation {
    CREATE,
    UPDATE,
    DELETE,
    READ
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>void check(Operation op) {
      switch(op) { // dart complains here
        case Operation.CREATE:
          insert();
          break;
        case Operation.UPDATE:
          update();
          break;
        case Operation.DELETE:
          delete();
          break;
  }
  </code></pre>
  
  <p>which complains with this error at the <code>switch(op)</code> line:</p>
  
  <blockquote>
    <p>error: Missing case clause for 'READ'.<br/>
    Try adding a case clause for the missing constant, or adding a default constant.</p>
  </blockquote>
  
  <p>It gets fixed if I follow the suggestion and add the <code>READ</code> case or a <code>default</code> case. <br/>
  But my question is : why is this so ? Why can't I leave out a case? What if I don't want to check that case here? I checked the <a href="https://dart.dev/guides/language/language-tour#enumerated-types" rel="nofollow noreferrer">dart language docs</a> which says :</p>
  
  <blockquote>
    <p>You can use enums in switch statements, and you’ll get a warning if you don’t handle all of the enum’s values</p>
  </blockquote>
  
  <p>But in my case, its definitely an error and not a warning.
  I'm using dart for developing a flutter application (if that makes a difference).</p>