handler

);

General rule for BuildContext

In general, use the following rule for a
BuildContext: if the closure doesn’t outlive
the widget, it’s ok to pass the context to the closure.

Stateful widgets require extra attention.
They consist of two classes: the widget and the
widget state,
where the widget is short living,
and the state is long living. The build context,
owned by the widget, should never be referenced
from the state’s fields, as the state won’t be garbage
collected together with the widget, and can significantly outlive it.

Memory leak vs memory bloat

In a memory leak, an application progressively uses memory,
for example, by repeatedly creating a listener,
but not disposing it.

Memory bloat uses more memory than is necessary for
optimal performance, for example, by using overly large
images or keeping streams open through their lifetime.