title: Creating a generic property in a Map object in Dart
body: <p>I have this map:</p>
  <pre><code>final x = {
    &quot;y&quot;: {},
    &quot;z&quot;: {},
  }
  </code></pre>
  <p>I want the $y property to hold an object with the type of $e inside of a property of type integer i.e:</p>
  <pre><code>x = {
    &quot;y&quot;: {
      1: {/*e*/},
      2: {/*e*/},
      3: {/*e*/},
    }
  }
  </code></pre>
  <p>While I want the $z property to to hold $g instead of $e, just like $y, but I want it to hold $g and not $e, i.e:</p>
  <pre><code>x = {
    &quot;y&quot;: {
      1: {/*e*/},
      2: {/*e*/},
      3: {/*e*/},
    },
    &quot;z&quot;: {
      1: {/*g*/},
      2: {/*g*/},
      3: {/*g*/},
    }
  }
  </code></pre>
  <p>I've tried the following:</p>
  <pre><code>final x = {
    Map&lt;int, e&gt; &quot;y&quot;: {},
    Map&lt;int, g&gt; &quot;z&quot;: {},
  }
  </code></pre>
  <p>This didn't work.</p>
  <p>I also tried:</p>
  <pre><code>x = {
    &quot;y&quot;: {
      1: Map&lt;e&gt;,
    },
    &quot;z&quot;: {
      1: Map&lt;g&gt;,
    }
  }
  </code></pre>
  <p>Also that didn't work,</p>
  <ul>
  <li>Note that $x, and $g are objects (instances) created by a class.</li>
  <li>When I say &quot;This didn't work&quot; I mean, it's showing an error.</li>
  </ul>
  <p>How can I do that in Dart?</p>