of static method

DIPlugin of(
  1. BuildContext context
)

Get the DIPlugin from the nearest DI scope. If no scope is found, it will fallback to the platform DIPlugin.

Implementation

static DIPlugin of(BuildContext context) {
  final scopeDI =
      context.dependOnInheritedWidgetOfExactType<_InheritedDIScope>()?.scope;

  if (scopeDI == null) {
    // Fallback to platform DI
    return vyuh.di;
  }

  return scopeDI;
}