title: How to print block_data based on block_type key value in dart
body: <p>I have a method where i iterate through list of objects. For each object i want to print the value of 'block_data' based on &quot;block_type&quot; in the order of above to below. Notice that sometimes the <code>block_type</code> <code>title</code> is above <code>text</code> and sometimes its below <code>text</code> in the list of objects.</p>
  <p>Sometimes i have other <code>block_types</code> like <code>graph-pie-chart</code> and i have <code>block_labels</code> for the chart and the <code>block_data</code> for the chart is also in a list based on <code>block_labels</code>. And all the <code>block_type</code> in the <code>List</code> coul be something else and another order. But i still want it in the order of the List of objects i get like the example below. I wonder how i can achieve this with dart?</p>
  <pre><code>class Book {
    getBookInfo() {
      final List listOfItems = [
        {&quot;block_type&quot;: &quot;title&quot;, &quot;block_data&quot;: &quot;Books&quot;},
        {&quot;block_type&quot;: &quot;text&quot;, &quot;block_data&quot;: &quot;This is the textblock of books&quot;},
        {&quot;block_type&quot;: &quot;text&quot;, &quot;block_data&quot;: &quot;This is the textblock of publishers&quot;},
        {&quot;block_type&quot;: &quot;title&quot;, &quot;block_data&quot;: &quot;Publishers&quot;},
        {&quot;block_type&quot;: &quot;graph-pie-chart&quot;, &quot;block_labels&quot;: [&quot;Total sold&quot;,&quot;Sold copies&quot;,&quot;Reviews&quot;], &quot;block_data&quot;: [&quot;3000&quot;, &quot;100&quot;, &quot;10&quot;]},
        {&quot;block_type&quot;: &quot;button&quot;, &quot;link&quot;: &quot;&lt;link to a bookshop&gt;&quot;},
      ];
      List selectedItem = listOfItems;
      selectedItem.forEach((index) {
  
        }
        ;
      });
    }
  }
  
  
  </code></pre>