title: Flutter: The widget values ​inside the ListView are not updated when an item is removed
body: <p>Hello I am new on flutter, I am work in a widget named split row, i use a ListView with three childrens: Text Widget, ListView Builder widget and a Container Widget.</p>
  
  <p>I use the Text for a Tittle, a Map to fill the ListView Builder, and the container to add widgets to  ListView Builder, every thing works fine but when i remove an item this item is removed from the map, from the ListView Builder too but not update the values.</p>
  
  <p>To explain myself better I made an example with a textField and a Text, in the first I entered the value of the map key three times and in the second the text is formed with the word data and the map key. This is what happened</p>
  
  <p><a href="https://i.stack.imgur.com/H03s2.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H03s2.gif" alt="enter image description here"></a></p>
  
  <p>As you can see when i delete data1 the item it disappears leaving only data 0, data 2 and data 3, but value 111 it remains and value 333 disappears. obviously values ​​do not correspond to map elements except 000 => data 0</p>
  
  <p>I have already been researching in forums, I have searched stackoverflow, on websites and I have not found anything that helps me</p>
  
  <p>This is the code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class SplitRow extends StatefulWidget {
    @override
    _SplitRowState createState() =&gt; _SplitRowState();
  }
  
  class _SplitRowState extends State&lt;SplitRow&gt; {
    int _index = 0;
    Map&lt;String, Widget&gt; splitRows = {};
    Map records = {};
    Map col1 = {};
  
    // Crete Widget Split Row
    Widget _splitRow(index) {
      return Column(
        children: &lt;Widget&gt;[
          Container(
            color: Colors.white,
            height: 40.0,
            child: Row(
              children: &lt;Widget&gt;[
                IconButton(
                  icon: Icon(Icons.remove_circle),
                  iconSize: 24,
                  color: Color(0xFFFF3B30),
                  onPressed: () {
                    removeItem(index);
                  },
                ),
                Container(
                  width: 100,
                  child: TextField(
                    keyboardType: TextInputType.numberWithOptions(
                      signed: false,
                      decimal: true,
                    ),
                    decoration: InputDecoration(
                      hintText: 'Put direction here...',
                      border: InputBorder.none,
                    ),
                    style: TextStyle(fontFamily: 'Lekton'),
                    onChanged: (value) {
                      col1["$index"] = value;
                    },
                  ),
                ),
                _VerticalDivider(),
                Text('data $index'),
              ],
            ),
          ),
          _HorizontalDivider(),
        ],
      );
    }
  
    // Create Widget Add Row
    Widget _addRow() {
      return Container(
        height: 40,
        color: Colors.white,
        child: Row(
          children: &lt;Widget&gt;[
            Container(
              height: 40,
              color: Colors.white,
              child: IconButton(
                icon: Icon(Icons.add_circle),
                iconSize: 24,
                color: Color(0xFF34C759),
                onPressed: () {
                  addItem();
                },
              ),
            ),
            Text('New Item')
          ],
        ),
      );
    }
  
    // Add splitRow
    void addItem() {
      int key = _index;
      print('Index antes $_index');
      setState(() {
        splitRows['$key'] = _splitRow(key);
        ++_index;
      });
      print(splitRows);
    }
  
    // Remove splitRow
    void removeItem(key) {
      setState(() {
        splitRows.remove('$key');
        col1.remove('$key');
      });
    }
  
    // Save Values
    void saveItems() {
      records = {'qty': col1};
      print(records);
    }
  
    @override
    void initState() {
      super.initState();
      splitRows['$_index'] = _splitRow(_index);
      ++_index;
      // splitRows['$_index'] = _addRow(_index);
      // ++_index;
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          appBar: AppBar(
            title: Text('Directions'),
            actions: &lt;Widget&gt;[
              FlatButton(
                child: Text(
                  'Save',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  saveItems();
                },
              )
            ],
          ),
          backgroundColor: Color(0xFFE5E5EA),
          body: Column(
            children: &lt;Widget&gt;[
              Container(
                  constraints: BoxConstraints(
                    minHeight: 40.0,
                    maxHeight: 500.0,
                    minWidth: double.infinity,
                    maxWidth: double.infinity,
                  ),
                  child: ListView(
                    children: &lt;Widget&gt;[
                      Padding(padding: EdgeInsets.only(top: 10.0)),
                      Text('DIRECTIONS'),
                      ListView.builder(
                        shrinkWrap: true,
                        itemCount: splitRows.length,
                        itemBuilder: (BuildContext context, int index) {
                          String key = splitRows.keys.elementAt(index);
                          return splitRows[key];
                        },
                        physics: NeverScrollableScrollPhysics(),
                      ),
                      _addRow()
                    ],
                  ))
            ],
          ));
    }
  }
  
  class _HorizontalDivider extends StatelessWidget {
    const _HorizontalDivider({
      Key key,
    }) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Container(
        color: Colors.white,
        child: Divider(
          height: 2.0,
        ),
      );
    }
  }
  
  class _VerticalDivider extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Container(
        height: 20,
        width: 2,
        margin: EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0),
        child: VerticalDivider(
          width: 2.0,
        ),
      );
    }
  }
  </code></pre>
  
  <p>I will be eternally grateful for any help or advice you can give me, I have been without a solution for a long time</p>