spotSingle<W extends Widget> function

  1. @useResult
  2. @Deprecated('Use spot<W>().atMost(1)')
WidgetSelector<W> spotSingle<W extends Widget>({
  1. List<WidgetSelector<Widget>> parents = const [],
  2. List<WidgetSelector<Widget>> children = const [],
})

Creates a chainable WidgetSelector that matches a single Widget of type W.

When executed this WidgetSelector will fail when it finds multiple Widgets of type W in widget tree.

This selector compares the Widgets by runtimeType rather than by super type (see WidgetTypeFilter). This makes sure that e.g. spotSingle<Align>() does not accidentally match a Center Widget, that extends Align.

If multiple Widgets of type W are expected, use spot instead.

Implementation

@useResult
@Deprecated('Use spot<W>().atMost(1)')
WidgetSelector<W> spotSingle<W extends Widget>({
  List<WidgetSelector> parents = const [],
  List<WidgetSelector> children = const [],
}) {
  return _global.spotSingle<W>(
    parents: parents,
    children: children,
  );
}