context property

BuildContext context

The location in the tree where this widget builds.

The framework associates State objects with a BuildContext after creating them with StatefulWidget.createState and before calling initState. The association is permanent: the State object will never change its BuildContext. However, the BuildContext itself can be moved around the tree.

After calling dispose, the framework severs the State object's.

connection with the BuildContext.

Implementation

BuildContext get context {
  assert(
    null != _element,
    'State.context instance cannot be accessed in a state constructor. '
    'Please use initState hook to initialize the state that depends on '
    'context or consider canceling any active work during "dispose". You '
    'can also use "mounted" getter to determine if context is available.',
  );

  return _element!;
}