debugOwnerLabel function

String? debugOwnerLabel(
  1. BuildContext context
)

Debug-mode name for a sling widget's scope: the type of the nearest enclosing app widget (LaunchesScreen), found by walking up to the SlingScope past render/proxy widgets and sling's own. null in release builds (type names are minified there), when the widget sits right under the SlingScope, or when there is none.

Implementation

String? debugOwnerLabel(BuildContext context) {
  var enabled = false;
  assert(enabled = true);
  if (!enabled) return null;
  String? found;
  context.visitAncestorElements((element) {
    final widget = element.widget;
    if (widget is SlingScope) return false;
    if (widget is! StatelessWidget && widget is! StatefulWidget) return true;
    if (widget is QueryBuilder ||
        widget is SlingRow ||
        widget is MutationBuilder ||
        widget is SubscriptionBuilder ||
        widget is PaginatedQueryBuilder ||
        widget is SlingRequestOverlay ||
        widget is Builder ||
        widget is StatefulBuilder) {
      return true;
    }
    final name = '${widget.runtimeType}';
    final generic = name.indexOf('<');
    found = generic < 0 ? name : name.substring(0, generic);
    return false;
  });
  return found;
}