Class that programmatically interacts with widgets.
For a variant of this class suited specifically for unit tests, see WidgetTester.
- Implemented by
Constructors
- WidgetController(WidgetsBinding binding)
-
Creates a widget controller that uses the given binding.
Properties
- allElements → Iterable<Element>
-
All elements currently in the widget tree (lazy pre-order traversal).
read-only - allRenderObjects → Iterable<RenderObject>
-
Render objects of all the widgets currently in the widget tree (lazy pre-order traversal).
read-only - allStates → Iterable<State>
-
All states currently in the widget tree (lazy pre-order traversal).
read-only - allWidgets → Iterable<Widget>
-
All widgets currently in the widget tree (lazy pre-order traversal).
read-only - binding → WidgetsBinding
-
A reference to the current instance of the binding.
read-only - layers → List<Layer>
-
Returns a list of all the
Layer
objects in the rendering.read-only - hashCode → int
-
Get a hash code for this object.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
any(
Finder finder) → bool -
Checks if
finder
exists in the tree. -
element(
Finder finder) → Element -
The matching element in the widget tree.
-
elementList(
Finder finder) → Iterable<Element> -
The matching elements in the widget tree.
-
firstElement(
Finder finder) → Element -
The first matching element according to a depth-first pre-order traversal of the widget tree.
-
firstRenderObject(
Finder finder) → RenderObject -
The render object of the first matching widget according to a depth-first pre-order traversal of the widget tree.
-
firstState(
Finder finder) → State -
The first matching state according to a depth-first pre-order traversal of the widget tree.
-
firstWidget(
Finder finder) → Widget -
The first matching widget according to a depth-first pre-order traversal of the widget tree.
-
fling(
Finder finder, Offset offset, double velocity, { int pointer: 1, Duration frameInterval: const Duration(milliseconds: 16) }) → Future<Null> -
Attempts a fling gesture starting from the center of the given widget, moving the given distance, reaching the given velocity.
-
flingFrom(
Point startLocation, Offset offset, double velocity, { int pointer: 1, Duration frameInterval: const Duration(milliseconds: 16) }) → Future<Null> -
Attempts a fling gesture starting from the given location, moving the given distance, reaching the given velocity.
-
getBottomLeft(
Finder finder) → Point -
Returns the point at the bottom left of the given widget. This point is not inside the object's hit test area.
-
getBottomRight(
Finder finder) → Point -
Returns the point at the bottom right of the given widget. This point is not inside the object's hit test area.
-
getCenter(
Finder finder) → Point -
Returns the point at the center of the given widget.
-
getSize(
Finder finder) → Size -
Returns the size of the given widget. This is only valid once the widget's render object has been laid out at least once.
-
getTopLeft(
Finder finder) → Point -
Returns the point at the top left of the given widget.
-
getTopRight(
Finder finder) → Point -
Returns the point at the top right of the given widget. This point is not inside the object's hit test area.
-
hitTestOnBinding(
Point location) → HitTestResult -
Forwards the given location to the binding's hitTest logic.
-
pump(
Duration duration) → Future<Null> -
Called to indicate that time should advance.
-
renderObject(
Finder finder) → RenderObject -
The render object of the matching widget in the widget tree.
-
renderObjectList(
Finder finder) → Iterable<RenderObject> -
The render objects of the matching widgets in the widget tree.
-
scroll(
Finder finder, Offset offset, { int pointer: 1 }) → Future<Null> -
Attempts to drag the given widget by the given offset, by starting a drag in the middle of the widget.
-
scrollAt(
Point startLocation, Offset offset, { int pointer: 1 }) → Future<Null> -
Attempts a drag gesture consisting of a pointer down, a move by the given offset, and a pointer up.
-
sendEventToBinding(
PointerEvent event, HitTestResult result) → Future<Null> -
Forwards the given pointer event to the binding.
-
startGesture(
Point downLocation, { int pointer: 1 }) → Future<TestGesture> -
Begins a gesture at a particular point, and returns the TestGesture object which you can use to continue the gesture.
-
state(
Finder finder) → State -
The matching state in the widget tree.
-
stateList(
Finder finder) → Iterable<State> -
The matching states in the widget tree.
-
tap(
Finder finder, { int pointer: 1 }) → Future<Null> -
Dispatch a pointer down / pointer up sequence at the center of the given widget, assuming it is exposed. If the center of the widget is not exposed, this might send events to another object.
-
tapAt(
Point location, { int pointer: 1 }) → Future<Null> -
Dispatch a pointer down / pointer up sequence at the given location.
-
widget(
Finder finder) → Widget -
The matching widget in the widget tree.
-
widgetList(
Finder finder) → Iterable<Widget> -
The matching widgets in the widget tree.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited