getParent abstract method

ApplicationContext? getParent()

Returns the parent context, if any.

Parent-child context relationships enable hierarchical configuration where child contexts inherit pods and configuration from their parents.

Hierarchical Benefits:

  • Configuration Inheritance: Child contexts inherit parent configuration
  • Pod Delegation: Children can access pods from parent contexts
  • Module Isolation: Separate modules with shared base configuration
  • Testing Flexibility: Test contexts with production-like parent setup

Example:

final parentContext = GenericApplicationContext();
await parentContext.refresh();

final childContext = GenericApplicationContext.withParent(parentContext);

// Child can access parent pods
final parentService = childContext.getPod<ParentService>(); // From parent
final childService = childContext.getPod<ChildService>();   // From child

print('Child parent: ${childContext.getParent()?.getId()}'); // Parent ID

Implementation

ApplicationContext? getParent();