Error thrown after deleting element from dynamically generated list view

Hello,

I have a list view and a button that generates list view items containing a text field on press. This works pretty well and I finally managed to figure out how to prevent all list items from rebuilding and all text fields loosing their content.

The trick for this if you are interested is using the unique key attribute for the list elements/components. This should in my opinion be more highlighted in the documentation or the widget builder. I used the following function to create keys:

int? createUniqueKey() {
  int uniqueKey = UniqueKey().hashCode;
  debugPrint("Created new unique key: ${uniqueKey}");
  return uniqueKey;
}

And now to the issue I am encountering: "Uncaught (in promise) Error: setState() called after dispose()"

This error get's thrown into my chrome developer console after I delete one of my list items. Even though the deletion works well and the app continues to work. This error will be thrown every time I continue to delete list items (without crashing the app).

Any suggestions to resolve this issue would be much appreciated :-)

4
1 reply