title: Flutter : How to Map values dynmically into list and iterate to its length and how can i do Update and Delete after maping values
body: <p>I am trying to build json expected output as below through dart programing for my application, I have mapped data to list successfully. But when I trying to delete / add the list, the elements in the list are not getting updated accordingly instead they are hgetting reapeted same data.</p>
  <p>Here is my code implimentation</p>
  <p>in this set state i am getting required values like Phone, name, email e.t.c</p>
  <pre><code>for (int i = 0; i &lt;= selectedContacts.length - 1; i++) {
          SimplifiedContact? contact = selectedContacts.elementAt(i);
  
          CreateContestModel(//&lt;-- from here i am getting required values.
            contact.phone, 
            contact.name,
            contact.email,
          );
        }
  </code></pre>
  <p>in below code i am, mapping data and building json</p>
  <pre><code>class CreateContestModel {
  
    static List models = [];
  
    String phone = '';
    String name = '';
    String email;
  
     CreateContestModel(this.phone, this.name, this.email) {
        var invitemap = {
        'name': name,
        'phone': phone,
        'email': email,
      };
  
      models.add(invitemap);
      print(models);
     }
  
  }
  </code></pre>
  <p><strong>Output</strong></p>
  <p><a href="https://i.stack.imgur.com/JCfj0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JCfj0.png" alt="enter image description here" /></a></p>
  <pre><code>{
     &quot;invitations&quot;:[
        {
           &quot;name&quot;:&quot;Acevedo Castro&quot;,
           &quot;phone&quot;:982-475-2009,
           &quot;email&quot;:&quot;floresjoyner@digifad.com&quot;
        },
        {
           &quot;name&quot;:&quot;Acevedo Castro&quot;,
           &quot;phone&quot;:982-475-2009,
           &quot;email&quot;:&quot;floresjoyner@digifad.com&quot;
        },
        {
           &quot;name&quot;:&quot;Abby Webster&quot;,
           &quot;phone&quot;:888-561-2141,
           &quot;email&quot;:&quot;howardnoel@perkle.com&quot;
        },
        {
           &quot;name&quot;:&quot;Abby Webster&quot;,
           &quot;phone&quot;:888-561-2141,
           &quot;email&quot;:&quot;howardnoel@perkle.com&quot;
        },
        {
           &quot;name&quot;:&quot;Abby Webster&quot;,
           &quot;phone&quot;:888-561-2141,
           &quot;email&quot;:&quot;howardnoel@perkle.com&quot;
        }
     ]
  }
  </code></pre>
  <p>As you see above items are not getting updated, but they are getting added more.</p>
  <p><strong>Expected Output</strong></p>
  <pre><code>{
     &quot;invitations&quot;:[
        {
           &quot;name&quot;:&quot;Acevedo Castro&quot;,
           &quot;phone&quot;:&quot;982-475-2009&quot;,
           &quot;email&quot;:&quot;floresjoyner@digifad.com&quot;
        },
        {
           &quot;name&quot;:&quot;Abby Webster&quot;,
           &quot;phone&quot;:&quot;888-561-2141&quot;,
           &quot;email&quot;:&quot;howardnoel@perkle.com&quot;
        }
     ]
  }
  </code></pre>