State can override

When a state object is no longer needed,
the framework calls dispose() on the state object.
Override the dispose function to do cleanup work.
For example, override dispose to cancel timers or to
unsubscribe from platform services. Implementations of
dispose typically end by calling super.dispose.

For more information, see State.

Keys

Use keys to control which widgets the framework matches up
with other widgets when a widget rebuilds. By default, the
framework matches widgets in the current and previous build
according to their runtimeType and the order in which they appear.
With keys, the framework requires that the two widgets have
the same key as well as the same runtimeType.

Keys are most useful in widgets that build many instances of
the same type of widget. For example, the ShoppingList widget,
which builds just enough ShoppingListItem instances to
fill its visible region: