devToolsBindingStatement function

Statement? devToolsBindingStatement(
  1. Binding binding,
  2. Expression? receiver,
  3. Expression value
)

Optionally returns a statement that records a binding for developer tools.

If binding is an @Input() binding, this returns an if statement that records the bound value for inspection when developer tooling is enabled:

if (isDevToolsEnabled) {
  ComponentInspector.instance.recordInput(component, 'name', value);
}

Otherwise, this returns null.

Implementation

Statement? devToolsBindingStatement(
  Binding binding,
  Expression? receiver,
  Expression value,
) {
  var target = binding.target;
  if (target is InputBinding) {
    return IfStmt(importExpr(DevTools.isDevToolsEnabled), [
      _recordInputStatement(receiver!, literal(target.templateName), value),
    ]);
  }

  return null;
}