Testable constructor

Testable(
  1. {@required Widget child,
  2. TestableGestures gestures,
  3. @required String id,
  4. String onRequestError(
      ),
    1. dynamic onRequestValue(
        ),
      1. ValueChanged onSetValue,
      2. String scrollableId}
      )

      Constructor for the Testable widget. If there is no TestRunner, or the runner is not enabled then this is a simple passthrough for the child.

      This requires an id for the test framework to be able to find the widget on the tree when running tests. Ideally this id is human readable but id can technically be any string that is valid w/in a ValueKey. If the id is either null or empty then this will disable the test framework for the child wildget and act as a simple passthrough.

      The gestures can be passed in as an override from the values set on the TestController. That is useful if the default gestures are already supported by this individual widget so providing a unique set of gestures for the Testable is desired.

      The scrollableId is typically only required if there are multiple Scollables on a page; such as a Netflix like vertical + horizontal scroll. When that happens, the framework will always find the top level scroll and can only find the secondary scroll if the scrollableId is passed in. The scrollableId is the value passed into the ValueKey on the key argument on the inner Scrollable.

      This provides multiple mechanisms to try to interact with the child widget. The first is to try to search the widget tree for widgets this knows how to interact with. This will search up to TestController.maxCommonSearchDepth for a widget it knows how to interact with. If none is found, or if the application would to provide custom logic, then the following callback methods are available:

      • onRequestError - Callback that will provide the current error message from the child widget.
      • onRequestValue - Callback that will provide the current value from the child widget.
      • onSetValue - Function that the framework can call to set the current value on the child widget.

      The list of Widgets this can auto-discover capabilities are as follows:

      Implementation

      Testable({
        @required this.child,
        this.gestures,
        @required this.id,
        this.onRequestError,
        this.onRequestValue,
        this.onSetValue,
        this.scrollableId,
      })  : assert(child != null),
            super(key: ValueKey(id));