WidgetSelector<W extends Widget> class

Represents a chain of widgets in the widget tree that can be asserted

Compared to normal Finder, this gives great error messages along the chain

Available Extensions

Constructors

WidgetSelector({required List<ElementFilter> stages, @Deprecated('Use quantityConstraint instead') ExpectedQuantity expectedQuantity = ExpectedQuantity.multi, QuantityConstraint? quantityConstraint, WidgetPresence? widgetPresence, W mapElementToWidget(Element element)?})
Constructor for creating a WidgetSelector.

Properties

children List<WidgetSelector<Widget>>
All child selectors of all stages this widget selector depends on
no setter
expectedQuantity ExpectedQuantity
Whether this selector expects to find a single or multiple widgets
no setter
hashCode int
The hash code for this object.
no setterinherited
mapElementToWidget → W Function(Element element)
Overwrite this method when W is a synthetic widget like AnyText that combines multiple widgets of similar (but not exact) Type
final
parents List<WidgetSelector<Widget>>
All parent selectors of all stages this widget selector depends on
no setter
quantityConstraint QuantityConstraint
The number of widgets that this selector expects to find
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
self WidgetSelector<W>
The WidgetSelector the chainable methods build upon.
no setter
stages List<ElementFilter>
The list of filters which are used to narrow down the selection of widgets in the tree
final
type Type
The runtime type of the widget this selector is intended for.
no setter
widgetPresence → WidgetPresence
Whether to include offstage widgets in the selection
final

Methods

atIndex(int index) WidgetSelector<W>
Selects the widget at a specified index in the list of found widgets.
inherited
copyWith({List<ElementFilter>? stages, ExpectedQuantity? expectedQuantity, QuantityConstraint? quantityConstraint, WidgetPresence? widgetPresence, W mapElementToWidget(Element element)?}) WidgetSelector<W>
Returns a new instance of WidgetSelector with some properties replaced with new values.
first() WidgetSelector<W>
Selects the first of n widgets
inherited
isAnyCombined() bool
Recursively checks if this or any parent selector includes onstage and offstage widgets
isAnyOffstage() bool
Recursively checks if this or any parent selector includes offstage widgets
last() WidgetSelector<W>
Selects the last of n widgets
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overrideWidgetPresence(WidgetPresence presence) WidgetSelector<W>
Creates a WidgetSelector that includes offstage widgets in the selection.
inherited
spot<W extends Widget>({List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that matches a all Widgets of type W that are in the scope of the parent WidgetSelector.
inherited
spotElement<W extends Widget>(Element element, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that finds the widget that is associated with element
inherited
spotIcon(IconData icon, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Icon>
Creates a WidgetSelector that finds all Icon widgets showing icon
inherited
spotIcons(IconData icon, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Icon>
Creates a WidgetSelector that finds all Icon widgets based on the icon
inherited
spotKey<W extends Widget>(Key key, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that finds widgets with the given key.
inherited
spotKeys<W extends Widget>(Key key, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that finds all widgets with the given key
inherited
spotOffstage({List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Widget>
Creates a WidgetSelector that includes offstage widgets in the selection.
inherited
spotSingle<W extends Widget>({List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that excludes offstage widgets from the selection.
inherited
spotSingleIcon(IconData icon, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Icon>
Creates a WidgetSelector that finds a single Icon based on the icon
inherited
spotSingleKey<W extends Widget>(Key key, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that finds a single widget with the given key.
inherited
spotSingleText<W extends Widget>(String text, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const [], bool findRichText = false}) WidgetSelector<W>
Creates a WidgetSelector that finds a single Text, EditableText or RichText where text is the content
inherited
spotSingleWidget<W extends Widget>(W widget, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that finds widget by identity and returns only that widget
inherited
spotText(Pattern text, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const [], bool exact = false}) WidgetSelector<AnyText>
Creates a WidgetSelector that finds text within the parent
inherited
spotTexts<W extends Widget>(String text, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const [], bool findRichText = false}) WidgetSelector<W>
Creates a WidgetSelector that finds all Text, EditableText or RichText where text is the content
inherited
spotTextWhere(void match(Subject<String>), {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const [], String? description}) WidgetSelector<AnyText>
Creates a WidgetSelector that finds text matching match in the parent
inherited
spotWidget<W extends Widget>(W widget, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that finds widget by identity and returns all occurrences of it in the widget tree
inherited
spotWidgets<W extends Widget>(W widget, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a WidgetSelector that finds all widget by identity
inherited
toString() String
A string representation of this object.
override
toStringBreadcrumb() String
Generates a breadcrumb-like string representation of this selector.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

all WidgetSelector<Widget>
Matches any widget currently mounted
final

Static Methods

defaultMapElementToWidget<W>(Element element) → W
Default mapping function to convert an Element to a widget of type W.

Constants

inheritanceSeparator → const String
Separator indicating a parent-child relationship between selectors
stageSeparator → const String
Separator splitting stages of a selector