spot library

Spot is a library for testing the Widget tree of Flutter apps.

Classes

Act
Entrypoint to interact with widgets found via spot.
AnyText
A union type for any text widget that can be found in the widget tree. Specifically this includes:
ChildFilter
Keeps all WidgetTreeNode that have child elements that match the childSelectors selectors
Context<T>
The context for a Subject that allows asserting expectations and creating nested subjects.
ElementFilter
Base class for defining filters on widget tree nodes.
Extracted<T>
A property extracted from a value being checked, or a rejection.
FinderFilter
An interop filter that filters elements based on a flutter_test Finder
MultiWidgetMatcher<W extends Widget>
A representation of multiple Widgets found by a WidgetSnapshot
NamedElementProp<T>
A property of an element that can be extracted from the element.
NamedRenderObjectProp<R extends RenderObject, T>
A property of a render object that can be extracted from the render object.
NamedWidgetProp<W extends Widget, T>
A property of a widget that can be extracted from the widget.
ParentFilter
A filter that checks if the candidates are children of all parents
PredicateFilter
Filters widget tree nodes based on a predicate
QuantityConstraint
Defines the quantity constraints for the number of widgets expected to be found.
Rejection
A description of a value that failed an expectation.
ScopedWidgetTreeSnapshot
A snapshot representing a specific subtree within a WidgetTreeSnapshot.
Screenshot
A screenshot taken from a widget test.
Subject<T>
A target for checking expectations against a value in a test.
WidgetMatcher<W extends Widget>
A representation of a single Widget found by a WidgetSnapshot with direct access to its element and the original selector.
WidgetSelector<W extends Widget>
Represents a chain of widgets in the widget tree that can be asserted
WidgetSnapshot<W extends Widget>
Represents a snapshot of widgets that have been discovered by a WidgetSelector.
WidgetTreeNode
A node in WidgetTreeSnapshot holding a single element and knows about parent and children.
WidgetTypeFilter<W extends Widget>
Filters candidates by widget type W comparing the runtime type.

Enums

ExpectedQuantity
Represents the expected quantity of widgets a selector should match.

Extensions

AlignGetter on WidgetMatcher<Align>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
AlignMatcher on WidgetMatcher<Align>
Matchers for the properties of Align provided via Diagnosticable.debugFillProperties
AlignSelector on WidgetSelector<Align>
Allows filtering Align by the properties provided via Diagnosticable.debugFillProperties
AnyTextGetter on WidgetMatcher<AnyText>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
AnyTextMatcher on WidgetMatcher<AnyText>
Matchers for the properties of AnyText provided via Diagnosticable.debugFillProperties
AnyTextSelector on WidgetSelector<AnyText>
Allows filtering AnyText by the properties provided via Diagnosticable.debugFillProperties
BoolChecks on Subject<bool>
CircularProgressIndicatorGetter on WidgetMatcher<CircularProgressIndicator>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
CircularProgressIndicatorMatcher on WidgetMatcher<CircularProgressIndicator>
Matchers for the properties of CircularProgressIndicator provided via Diagnosticable.debugFillProperties
CircularProgressIndicatorSelector on WidgetSelector<CircularProgressIndicator>
Allows filtering CircularProgressIndicator by the properties provided via Diagnosticable.debugFillProperties
ColumnGetter on WidgetMatcher<Column>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
ColumnMatcher on WidgetMatcher<Column>
Matchers for the properties of Column provided via Diagnosticable.debugFillProperties
ColumnSelector on WidgetSelector<Column>
Allows filtering Column by the properties provided via Diagnosticable.debugFillProperties
ComparableChecks on Subject<Comparable<T>>
ConstrainedBoxGetter on WidgetMatcher<ConstrainedBox>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
ConstrainedBoxMatcher on WidgetMatcher<ConstrainedBox>
Matchers for the properties of ConstrainedBox provided via Diagnosticable.debugFillProperties
ConstrainedBoxSelector on WidgetSelector<ConstrainedBox>
Allows filtering ConstrainedBox by the properties provided via Diagnosticable.debugFillProperties
ContainerGetter on WidgetMatcher<Container>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
ContainerMatcher on WidgetMatcher<Container>
Matchers for the properties of Container provided via Diagnosticable.debugFillProperties
ContainerSelector on WidgetSelector<Container>
Allows filtering Container by the properties provided via Diagnosticable.debugFillProperties
ContextExtension on Subject<T>
CoreChecks on Subject<T>
CreateMatchers on WidgetSelector<W>
Extension on WidgetSelector that allows to generate matchers for the properties of a widget.
DefaultWidgetMatchers on WidgetMatcher<W>
DefaultWidgetSelectors on WidgetSelector<W>
DiagnosticPropWidgetMatcher on WidgetMatcher<W>
All DiagnosticsProperty related matchers
DiagnosticPropWidgetSelector on WidgetSelector<W>
All DiagnosticsProperty related selectors
EditableTextGetter on WidgetMatcher<EditableText>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
EditableTextMatcher on WidgetMatcher<EditableText>
Matchers for the properties of EditableText provided via Diagnosticable.debugFillProperties
EditableTextSelector on WidgetSelector<EditableText>
Allows filtering EditableText by the properties provided via Diagnosticable.debugFillProperties
EffectiveTextMatcher on WidgetMatcher<Text>
Matchers for the Text widget to make assertions about:
EffectiveTextSelector on WidgetSelector<Text>
Selectors for the Text widget based on properties like
ElementScreenshotExtension on Element
Provides the ability to create screenshots of an Element
ElevatedButtonGetter on WidgetMatcher<ElevatedButton>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
ElevatedButtonMatcher on WidgetMatcher<ElevatedButton>
Matchers for the properties of ElevatedButton provided via Diagnosticable.debugFillProperties
ElevatedButtonSelector on WidgetSelector<ElevatedButton>
Allows filtering ElevatedButton by the properties provided via Diagnosticable.debugFillProperties
FinderToSpot on Finder
Extensions that convert from the Finder API to spot
FloatingActionButtonGetter on WidgetMatcher<FloatingActionButton>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
FloatingActionButtonMatcher on WidgetMatcher<FloatingActionButton>
Matchers for the properties of FloatingActionButton provided via Diagnosticable.debugFillProperties
FloatingActionButtonSelector on WidgetSelector<FloatingActionButton>
Allows filtering FloatingActionButton by the properties provided via Diagnosticable.debugFillProperties
FunctionChecks on Subject<T Function()>
GridViewGetter on WidgetMatcher<GridView>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
GridViewMatcher on WidgetMatcher<GridView>
Matchers for the properties of GridView provided via Diagnosticable.debugFillProperties
GridViewSelector on WidgetSelector<GridView>
Allows filtering GridView by the properties provided via Diagnosticable.debugFillProperties
IconButtonGetter on WidgetMatcher<IconButton>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
IconButtonMatcher on WidgetMatcher<IconButton>
Matchers for the properties of IconButton provided via Diagnosticable.debugFillProperties
IconButtonSelector on WidgetSelector<IconButton>
Allows filtering IconButton by the properties provided via Diagnosticable.debugFillProperties
IconGetter on WidgetMatcher<Icon>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
IconMatcher on WidgetMatcher<Icon>
Matchers for the properties of Icon provided via Diagnosticable.debugFillProperties
IconSelector on WidgetSelector<Icon>
Allows filtering Icon by the properties provided via Diagnosticable.debugFillProperties
ImageGetter on WidgetMatcher<Image>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
ImageMatcher on WidgetMatcher<Image>
Matchers for the properties of Image provided via Diagnosticable.debugFillProperties
ImageSelector on WidgetSelector<Image>
Allows filtering Image by the properties provided via Diagnosticable.debugFillProperties
IterableChecks on Subject<Iterable<T>>
LinearProgressIndicatorGetter on WidgetMatcher<LinearProgressIndicator>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
LinearProgressIndicatorMatcher on WidgetMatcher<LinearProgressIndicator>
Matchers for the properties of LinearProgressIndicator provided via Diagnosticable.debugFillProperties
LinearProgressIndicatorSelector on WidgetSelector<LinearProgressIndicator>
Allows filtering LinearProgressIndicator by the properties provided via Diagnosticable.debugFillProperties
ListTileGetter on WidgetMatcher<ListTile>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
ListTileMatcher on WidgetMatcher<ListTile>
Matchers for the properties of ListTile provided via Diagnosticable.debugFillProperties
ListTileSelector on WidgetSelector<ListTile>
Allows filtering ListTile by the properties provided via Diagnosticable.debugFillProperties
MapChecks on Subject<Map<K, V>>
MatchPropNonNullable on MatchProp<T?>
Extension on MatchProp<T?> to handle non-nullable types.
MatchPropNullable on MatchProp<T>
Extension on MatchProp<T> to handle nullable types.
MultiWidgetMatcherExtensions on MultiWidgetMatcher<W>
Extension on MultiWidgetMatcher
MultiWidgetSelectorMatcher on WidgetSnapshot<W>
Extension on WidgetSnapshot
MutateStages on WidgetSelector<W>
Allows modification of stages of a WidgetSelector
NullableChecks on Subject<T?>
NumChecks on Subject<num>
OpacityGetter on WidgetMatcher<Opacity>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
OpacityMatcher on WidgetMatcher<Opacity>
Matchers for the properties of Opacity provided via Diagnosticable.debugFillProperties
OpacitySelector on WidgetSelector<Opacity>
Allows filtering Opacity by the properties provided via Diagnosticable.debugFillProperties
OutlinedButtonGetter on WidgetMatcher<OutlinedButton>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
OutlinedButtonMatcher on WidgetMatcher<OutlinedButton>
Matchers for the properties of OutlinedButton provided via Diagnosticable.debugFillProperties
OutlinedButtonSelector on WidgetSelector<OutlinedButton>
Allows filtering OutlinedButton by the properties provided via Diagnosticable.debugFillProperties
PropSelectorQueries on ChainableSelectors<W>
The newer version of WidgetSelector.withProp that uses NamedWidgetProp.
QuantityMatchers on WidgetSelector<W>
Extension on WidgetSelector<W> providing matchers to assert on the quantity of selected widgets.
QuantitySelectors on WidgetSelector<W>
Extension on WidgetSelector<W> providing methods to specify the quantity of widgets to select. These methods allow setting specific quantity constraints for the selection of widgets.
ReadSingleSnapshot on WidgetSelector<W>
Extension on WidgetSelector<W> to provide easy access to the single widget, element, or render object in the current selection.
RelativeSelectors on WidgetSelector<W>
Extensions that control the parent/children widgets of a WidgetSelector
RowGetter on WidgetMatcher<Row>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
RowMatcher on WidgetMatcher<Row>
Matchers for the properties of Row provided via Diagnosticable.debugFillProperties
RowSelector on WidgetSelector<Row>
Allows filtering Row by the properties provided via Diagnosticable.debugFillProperties
SafeAreaGetter on WidgetMatcher<SafeArea>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
SafeAreaMatcher on WidgetMatcher<SafeArea>
Matchers for the properties of SafeArea provided via Diagnosticable.debugFillProperties
SafeAreaSelector on WidgetSelector<SafeArea>
Allows filtering SafeArea by the properties provided via Diagnosticable.debugFillProperties
SelectableTextGetter on WidgetMatcher<SelectableText>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
SelectableTextMatcher on WidgetMatcher<SelectableText>
Matchers for the properties of SelectableText provided via Diagnosticable.debugFillProperties
SelectableTextSelector on WidgetSelector<SelectableText>
Allows filtering SelectableText by the properties provided via Diagnosticable.debugFillProperties
SelectorQueries on WidgetSelector<W>
Extension on WidgetSelector<W> for advanced widget querying.
SelectorScreenshotExtension on WidgetSelector<W>
Provides the ability to create screenshots of a WidgetSelector
SelectorToSnapshot on WidgetSelector<W>
Extension on WidgetSelector<W> to create snapshots of the current widget selection.
SemanticsGetter on WidgetMatcher<Semantics>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
SemanticsMatcher on WidgetMatcher<Semantics>
Matchers for the properties of Semantics provided via Diagnosticable.debugFillProperties
SemanticsSelector on WidgetSelector<Semantics>
Allows filtering Semantics by the properties provided via Diagnosticable.debugFillProperties
SizedBoxGetter on WidgetMatcher<SizedBox>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
SizedBoxMatcher on WidgetMatcher<SizedBox>
Matchers for the properties of SizedBox provided via Diagnosticable.debugFillProperties
SizedBoxSelector on WidgetSelector<SizedBox>
Allows filtering SizedBox by the properties provided via Diagnosticable.debugFillProperties
SkipExtension on Subject<T>
SliderGetter on WidgetMatcher<Slider>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
SliderMatcher on WidgetMatcher<Slider>
Matchers for the properties of Slider provided via Diagnosticable.debugFillProperties
SliderSelector on WidgetSelector<Slider>
Allows filtering Slider by the properties provided via Diagnosticable.debugFillProperties
SnapshotScreenshotExtension on WidgetSnapshot<W>
Provides the ability to create screenshots of a WidgetSnapshot
SpotToFinder on WidgetSelector<W>
Extensions that convert the spot API to the Finder API
StringChecks on Subject<String>
SwitchGetter on WidgetMatcher<Switch>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
SwitchMatcher on WidgetMatcher<Switch>
Matchers for the properties of Switch provided via Diagnosticable.debugFillProperties
SwitchSelector on WidgetSelector<Switch>
Allows filtering Switch by the properties provided via Diagnosticable.debugFillProperties
TextButtonGetter on WidgetMatcher<TextButton>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
TextButtonMatcher on WidgetMatcher<TextButton>
Matchers for the properties of TextButton provided via Diagnosticable.debugFillProperties
TextButtonSelector on WidgetSelector<TextButton>
Allows filtering TextButton by the properties provided via Diagnosticable.debugFillProperties
TextFieldGetter on WidgetMatcher<TextField>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
TextFieldMatcher on WidgetMatcher<TextField>
Matchers for the properties of TextField provided via Diagnosticable.debugFillProperties
TextFieldSelector on WidgetSelector<TextField>
Allows filtering TextField by the properties provided via Diagnosticable.debugFillProperties
TextGetter on WidgetMatcher<Text>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
TextMatcher on WidgetMatcher<Text>
Matchers for the properties of Text provided via Diagnosticable.debugFillProperties
TextSelector on WidgetSelector<Text>
Allows filtering Text by the properties provided via Diagnosticable.debugFillProperties
TextStyleSubject on Subject<TextStyle>
Allows accessing various properties of TextStyle.
TooltipGetter on WidgetMatcher<Tooltip>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
TooltipMatcher on WidgetMatcher<Tooltip>
Matchers for the properties of Tooltip provided via Diagnosticable.debugFillProperties
TooltipSelector on WidgetSelector<Tooltip>
Allows filtering Tooltip by the properties provided via Diagnosticable.debugFillProperties
ToWidgetMatcher on WidgetSnapshot<W>
Extension on WidgetSnapshot<W> to convert it to WidgetMatcher types.
WidgetMatcherExtensions on WidgetMatcher<W>
Extension on WidgetMatcher
WidgetSelectorProp on WidgetSelector<W>
Allows narrowing down the search to widgets that match a specific properties
WidgetSnapshotShorthands on WidgetSnapshot<W>
Extension on WidgetSnapshot
WrapGetter on WidgetMatcher<Wrap>
Retrieves the DiagnosticsProperty of the matched widget with propName of type T
WrapMatcher on WidgetMatcher<Wrap>
Matchers for the properties of Wrap provided via Diagnosticable.debugFillProperties
WrapSelector on WidgetSelector<Wrap>
Allows filtering Wrap by the properties provided via Diagnosticable.debugFillProperties

Constants

act → const Act
Top level entry point to interact with widgets on the screen.
useResult → const UseResult
Used to annotate a method, field, or getter within a class, mixin, or extension, or a or top-level getter, variable or function to indicate that the value obtained by invoking it should be used. A value is considered used if it is assigned to a variable, passed to a function, or used as the target of an invocation, or invoked (if the result is itself a function).

Properties

allWidgets WidgetSelector<Widget>
A WidgetSelector that matches all widgets in the widget tree.
no setter

Functions

check<T>(T value, {String? because}) Subject<T>
Creates a Subject that can be used to validate expectations against value, with an exception upon a failed expectation.
elementProp<T>(String name, T get(Element element)) NamedElementProp<T>
A property of an Element with a name that can be extracted with get.
renderObjectProp<T, R extends RenderObject>(String name, T get(R renderObject)) NamedRenderObjectProp<R, T>
A property of a RenderObject with a name that can be extracted with get.
spot<W extends Widget>({List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that matches a all Widgets of type W in widget tree.
spotAllWidgets() WidgetSelector<Widget>
A WidgetSelector that matches all widgets in the widget tree.
spotElement<W extends Widget>(Element element, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that finds the widget that is currently associated to the given element.
spotIcon(IconData icon, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Icon>
Creates a chainable WidgetSelector that finds a Icon based on IconData icon
spotIcons(IconData icon, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Icon>
Creates a chainable WidgetSelector that finds all widgets of type Icon that have icon as IconData
spotKey<W extends Widget>(Key key, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that finds a widget with the given key.
spotKeys<W extends Widget>(Key key, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that finds all widgets with the given key.
spotOffstage({List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Widget>
Creates a WidgetSelector that includes only offstage widgets in the selection.
spotSingle<W extends Widget>({List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that matches a single Widget of type W.
spotSingleIcon(IconData icon, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<Icon>
Creates a chainable WidgetSelector that finds an Icon based on IconData icon
spotSingleKey<W extends Widget>(Key key, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that finds a widget with the given key.
spotSingleText<W extends Widget>(String text, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const [], bool findRichText = false}) WidgetSelector<W>
Either finds Text or EditableText Widgets.
spotSingleWidget<W extends Widget>(W widget, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that matches a single Widget by identity
spotText(Pattern text, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const [], bool exact = false}) WidgetSelector<AnyText>
Finds text on the screen
spotTexts<W extends Widget>(String text, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const [], bool findRichText = false}) WidgetSelector<W>
Either finds Text or EditableText Widgets (set W accordingly).
spotTextWhere(void match(Subject<String>), {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<AnyText>
Finds text matching match on the screen
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
spotWidgets<W extends Widget>(W widget, {List<WidgetSelector<Widget>> parents = const [], List<WidgetSelector<Widget>> children = const []}) WidgetSelector<W>
Creates a chainable WidgetSelector that finds all widget by identity
takeScreenshot({Element? element, WidgetSnapshot<Widget>? snapshot, WidgetSelector<Widget>? selector, String? name}) Future<Screenshot>
Takes a screenshot of the entire screen or a single widget.
widgetProp<W extends Widget, T>(String name, T get(W widget)) NamedWidgetProp<W, T>
A property of a Widget with a name that can be extracted with get.

Typedefs

AsyncCondition<T> = FutureOr<void> Function(Subject<T>)
A callback that asynchronously checks expectations against a subject.
Condition<T> = void Function(Subject<T>)
A callback that synchronously checks expectations against a subject.
MatchProp<T> = void Function(Subject<T>)
A Function that fires checks against T using the Subject API
MultiWidgetSelector<W extends Widget> = WidgetSelector<W>
A WidgetSelector that to 0..N widgets
MultiWidgetSnapshot<W extends Widget> = WidgetSnapshot<W>
A type alias for a snapshot that can contain multiple widgets.
SingleWidgetSelector<W extends Widget> = WidgetSelector<W>
A WidgetSelector that intends to resolve to a single widget
SingleWidgetSnapshot<W extends Widget> = WidgetSnapshot<W>
A type alias for a snapshot that contains a single widget.

Exceptions / Errors

PropertyCheckFailure
Represents a failure in a property check within widget testing.