appendTo method Null safety

Element appendTo(
  1. Widget parent,
  2. [Object? cacheKey]
)

Use this method inside of the build method of the parent widget to append this widget to it. This creates a widget tree and makes it possible to use the findParent() and setState() method.

Implementation

Element appendTo(Widget parent, [Object? cacheKey]) {
  _parent = parent;
  initState();
  return wrapWithElement();
}