title: How to change List<String> to List<dynamic> in Dart 2?
body: <p>I have a <code>List&lt;String&gt;</code> and I need to change it to <code>List&lt;dynamic&gt;</code> in Dart 2. </p>
  
  <p>First, I tried this code but it doesn't work:</p>
  
  <pre><code>var str_list = ["aa", "bb"];
  
  // fails - is not dynamic
  // gives List&lt;String&gt; 
  List&lt;dynamic&gt; target_list_0 = str_list;
  </code></pre>
  
  <p>Later, I tried these 2 ways:</p>
  
  <pre><code>// succeeds - is dynamic
  // gives List&lt;dynamic&gt; 
  var target_list_1 = [] + str_list;
  
  // succeeds - is dynamic
  // gives List&lt;dynamic&gt; 
  var target_list_2 = List&lt;dynamic&gt;.from(str_list);
  </code></pre>
  
  <p>It works but I am not sure it is the best (or idiomatic) way to fix the problem. I would like to write my Dart-2 code as clean as possible, could you help?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>@matanlurey asked clear example where this pattern is necessary and how I am using it. </p>
  
  <p>I am developing something like twitter but more complex (not only #hashtags and @mentions but words that have internal structure). So, I make some modification of the source text, then split it by whitespace (or parentheses) to words and then examine word by word. If the word is special I change the string to a map (containing parsed info). The change is happening in-place in the list. And that is where I need it <code>dynamic</code>. I have this source code:</p>
  
  <pre><code>var split_regexp = new RegExp(r"[^\s\(\)]+|[\s\(\)]+");
  var body_matches = split_regexp.allMatches(body_part);
  
  var body = [] + body_matches.map(
      (m) =&gt; m.group(0)
  ).toList();
  
  // ... processing it ...
  </code></pre>
  
  <p>Currently, I am rewriting it from javascript (to which I rewrote it from python). Both the languages are able to catch the text by which I split words, it is much easier:</p>
  
  <pre><code>// python
  body = re.split(r"([\s\(\)]+)", body)
  
  // javascript
  body = body.split(/([\s\(\)]+)/g)
  </code></pre>
  
  <p>Is it possible to write it so simple in Dart? I think not - because I need the splitter whitespace (or splitter parentheses or anything in future versions of my app) and dart <code>split</code> doesn't catch it.</p>