v0.7.0
-
New prop API with
hasWidgetProp()
makes it easy to filter and assert properties of Widgets.
This replaces the oldhasProp()
method which was based on way to complicated package:checks context.// Old ⛈️ spotSingle<Checkbox>().existsOnce().hasProp( selector: (e) => e.context.nest( () => ['Checkbox', 'value'], (e) => Extracted.value((e.widget as Checkbox).value), ), match: (it) => it.equals(true), );
// New ✨ spotSingle<Checkbox>().existsOnce().hasWidgetProp( prop: widgetProp('value', (widget) => widget.value), match: (value) => value.isTrue(), );
The prop API is also available for
Element
andRenderObject
.New API methods for the prop API ├── Interface "NamedWidgetProp" added ├── Interface "NamedElementProp" added ├── Interface "NamedRenderObjectProp" added ├── Function "widgetProp" added ├── Function "elementProp" added ├── Function "renderObjectProp" added ├─┬ Class SelectorQueries │ ├── Method "whereWidgetProp" added │ ├── Method "whereElementProp" added │ └── Method "whereRenderObjectProp" added └─┬ Class WidgetMatcherExtensions ├── Method "getWidgetProp" added ├── Method "hasWidgetProp" added ├── Method "getElementProp" added ├── Method "hasElementProp" added ├── Method "getRenderObjectProp" added └── Method "hasRenderObjectProp" added
-
Never miss asserting your
WidgetSelector
.
All methods returning aWidgetSelector
are now annotated with@useResult
.
This will cause a lint warning when you only define aWidgetSelector
without asserting it.spot<FloatingActionButton>().withChild(spotIcons(Icons.add)); // warning, no assertion final plusFab = spot<FloatingActionButton>().withChild(spotIcons(Icons.add)); // ok, assigned spot<FloatingActionButton>().withChild(spotIcons(Icons.add)).existsOnce(); // ok, asserted
-
It is now easy to directly access the Widget of a
SingleWidgetSelector
withsnapshotWidget()
.
It also works for the associatedElement
andRenderObject
. UsesnapshotElement()
andsnapshotRenderObject()
.-final checkbox = spotSingle<Checkbox>().snapshot().widget; +final checkbox = spotSingle<Checkbox>().snapshotWidget(); print(checkbox.checkColor);