maybeOf static method

WiredashController? maybeOf(
  1. BuildContext context
)

The WiredashController from the closest Wiredash instance or null that encloses the given context.

Use it to start Wiredash (when available)

Wiredash.maybeOf(context)?.show();

Implementation

static WiredashController? maybeOf(BuildContext context) {
  final state = context.findAncestorStateOfType<WiredashState>();
  if (state == null) return null;
  // cache context in a short lived object like the widget
  // it gets later retrieved by the `show()` method to read the theme
  state.widget.showBuildContext = context;
  return WiredashController(state._services.wiredashModel);
}