title: Deleting an Item from one list using indexWhere() when presisng a button on an item from a different list Flutter
body: <p>So far I have declared a FavoriteItems class like so:</p>
  <pre><code>enum Type {
    a,
    b,
    c,
  }
  
  class FavoriteItem {
    final String id;
    final String itemType;
    final String title;
    final String icon;
    final String item;
    final Type type;
  
    FavoriteItem({
      required this.id,
      required this.itemType,
      required this.title,
      required this.icon,
      required this.item,
      required this.type,
    });
  
    FavoriteItem copyWith({
      String? id,
      String? itemType,
      String? title,
      String? icon,
      String? item,
      Type? type,
    }) {
      assert(tags != null);
      return FavoriteItem(
        id: id ?? this.id,
        itemType: itemType ?? this.itemType,
        title: title ?? this.title,
        icon: icon ?? this.icon,
        item: item ?? this.item,
        type: type ?? this.type,
      );
    }
  }
  </code></pre>
  <p>And have succesfully implemented a manager to add items from other lists to this list, and from the favorites screen to be able to safely delete it... buuut, On the screen where the items to be favorited are I run into the problem of not being able to write the propper getter to be able to remove this element from the favorites list when clicking again on the heart icon.</p>
  <pre><code>IconButton(
                onPressed: () {
                  if (_isFavorite == false) {
                    setState(() {
                      _isFavorite = true;
                    });
                    final manager =
                        Provider.of&lt;FavoritesManager&gt;(context, listen: false);
                    manager.addItem(
                      FavoriteItem(
                          id: widget.mitem.id,
                          itemType: widget.mitem.itemType,
                          title: widget.mitem.title,
                          icon: widget.mitem.icon,
                          item: widget.mitem.item,
                          type: Type.a),
                    );
                  }
                  if (_isFavorite == true) {
                    setState(() {
                      _isFavorite = !_isFavorite;
                    });
                    final manager =
                        Provider.of&lt;FavoritesManager&gt;(context, listen: false);
  
                    manager.deleteItem(favoriteItem
                        .indexWhere(widget.mitem.id = favoriteItems.id));
                  }
                },
                icon: Icon(_isFavorite ? Icons.favorite : Icons.favorite_border),
              )
  </code></pre>
  <p>I have tried things like</p>
  <pre><code>final FavoriteItem favoriteitem
  </code></pre>
  <p>And</p>
  <pre><code>final _favoriteItems = &lt;FavoriteItem&gt;[];
  
    List&lt;FavoriteItem&gt; get favoriteItems =&gt; List.unmodifiable(_favoriteItems);
  </code></pre>
  <p>But they all either show errors at the very &quot;getter&quot; line or later mention that the favoriteitem does not have an id declared.</p>
  <p>My question is, how do I properly call for the favorite items list so as to be able to use the indexwhere method to successfully remove the item from the favorites list?</p>
  <p>I am of course a complete begginner</p>