An Element is created internally by a Widget . Its main purpose is to know where in the widget tree is the widget that created it.

Elements are expensive to create and if it’s possible, they should be reused. That can be achieved with Keys ( ValueKeys and GlobalKeys ).

Element’s life cycle

Mount — it’s called when the element is added to the tree for the first time

Activate — it’s called when activating previously deactivated element

Update — updates the RenderObject with new data

with new data Deactivate — it’s called when the Element is removed/moved from the Widget tree. An Element can be still reactivated if it was moved during the same Frame and it has a GlobalKey

is removed/moved from the tree. An can be still reactivated if it was moved during the same Frame and it has a Unmount — if the Element was not reactivated during a Frame, it will be unmounted and cannot be reused anymore

To improve performance we need to use activate and update as often a possible and try to avoid triggering unmount and mount.

IMPORTANT: Most of the time you do not need special optimization as Flutter is fast, the following I would recommend using when you want to fix a visible performance problem.

Changing position in a Column/Row