title: How can I get the index of a widget in a list?
body: <p>I can a little bit confuse on how should I implement the delete function.</p>
  <p><a href="https://i.stack.imgur.com/FQ4TO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FQ4TO.png" alt="enter image description here" /></a></p>
  <p>By tapping the bottom button will add a Custom Card widget to the widget list that shows up on the top</p>
  <p>This is the function for that</p>
  <pre><code>onTap: () {
                    setState(() {
                      _variationCards.add(VariationCard(
                        key: UniqueKey(),
                        variation: Variation.empty,
                        index: _variationCards.length,
                        onRemoveCard: (index) {
                          setState(() {
                            _variationCards.removeAt(index);
                          });
                        },
                      ));
                    });
                  },
  </code></pre>
  <p>The problems of the current setup are</p>
  <ol>
  <li>Lets say I delete the second Card, now that the third Card became the second Card, but the index I passed to the third Card widget is still 2 when it is actually 1 now.</li>
  <li>I need the index in the Card widget because I need to have additional widget for the first card, but now If I delete the first card, the second card index value will not be updated.</li>
  </ol>
  <p>I think I am heading to the wrong path to implement this. Any help would be much appreciated.</p>
  <p>Thank you in advanced.</p>