title: How to remove an element from List of Widgets in flutter?
body: <p>I made a list of TableRows in flutter whichI passed as a children to my Table widget .Each row has some data and a flat button at the end which deletes the data from by database and I want to delete it from that list of TableRows also on the go .I know i have to use change the whole list under setState function but its not actually happening. What happens is it deletes from the database but the my UI remains same but when i go to previous screen and come back to that then its not there .So basically i able to delete it from database but not from UI</p>
  <pre><code>class _DataPreviewScreenState extends State&lt;DataPreviewScreen&gt; {
    List&lt;TableRow&gt; listView = [];
    void initState() {
      super.initState();
      finalData = widget.data; //&lt;- final data is my data from Database its actually a Map&lt;String,dynamic&gt;
      listView=listCreater();
    }
  
    List&lt;TableRow&gt; listCreater() { //&lt;-here im am making the list of TableRow Widgets
      List&lt;TableRow&gt; list = [
        TableRow(
          children: [
            RowHead(heading: 'Site'),
            RowHead(heading: 'UserName'),
            RowHead(heading: 'Password'),
            RowHead(heading: ' '),
          ],
        ),
      ];
      var i;
      for (var data in finalData) {
        var item = TableRow(
          key: UniqueKey(),
          decoration: BoxDecoration(shape: BoxShape.rectangle),
          children: [
            RowCell(data['site_name']),
            RowCell(data['user_name']),
            RowCell(data['password']),
            Container(
              height: 35.0,
              color: Colors.white,
              child: FlatButton(
                onPressed: () {   //&lt;- removing That particular list item from database
                  DataModel.instance.delete(data['_id']);
                  setState(() {
                    listView.removeAt(i);   /&lt;-trying to delete from UI
                  });
                },
                child: Icon(
                  Icons.delete,
                  size: 20.0,
                ),
              ),
            ),
          ],
        );
        list.add(item);
        i++;
      }
  
      return list;
    }
  </code></pre>
  <p>Place where i'm passing the rows</p>
  <pre><code>Container(
    child: Table(
      columnWidths: {3: FractionColumnWidth(0.1)},
      children: listView,
    ),
  ),
  </code></pre>
  <p>How the Ui looks currently</p>
  <p><a href="https://i.stack.imgur.com/V20Ial.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V20Ial.jpg" alt="Thats how the UI looks" /></a></p>
  <p>please help me with the problem or give me any reference to the article or something about keys or any suggestion in my logic like whats the common practise to do it or something.
  Thank You</p>