title: How to implement `assert()` for Type / T
body: <p>to reproduce:</p>
  <ul>
  <li>create an empty project</li>
  <li>paste the code below in <code>main.dart </code></li>
  <li>press f5 (in vs code, else just run the app)</li>
  </ul>
  <p>note that <a href="https://dartpad.dartlang.org/" rel="nofollow noreferrer">dartpad</a> <a href="https://github.com/dart-lang/dart-pad/issues/310" rel="nofollow noreferrer">ignores assert</a></p>
  <pre class="lang-dart prettyprint-override"><code>class Foo&lt;T&gt; {
    Foo(this.data) : assert(T is int || T is String);
    final T data;
  }
  
  void main() {
    print('hello');
    final _fooInt = Foo&lt;int&gt;(1);
  }
  
  </code></pre>
  <p>logs:</p>
  <pre class="lang-sh prettyprint-override"><code>flutter: hello
  [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: 'package:type_test/main.dart': Failed assertion: line 2 pos 27: 'T is int || T is String': is not true.
  #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
  #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
  #2      new Foo
  package:type_test/main.dart:2
  #3      main
  package:type_test/main.dart:8
  #4      _runMainZoned.&lt;anonymous closure&gt;.&lt;anonymous closure&gt; (dart:ui/hooks.dart:136:25)
  #5      _rootRun (dart:async/zone.dart:1186:13)
  #6      _CustomZone.run (dart:async/zone.dart:1090:19)
  
  </code></pre>
  <p>How can I implement correctly the assertion on line 2?
  Thank you</p>