down method

Future<TestGesture> down (Offset downLocation, { int pointer: 1, @required HitTester hitTester, @required EventDispatcher dispatcher })

Create a TestGesture by starting with a pointerDown at the given point.

By default, the pointer identifier used is 1. This can be overridden by providing the pointer argument.

A function to use for hit testing should be provided via the hitTester argument, and a function to use for dispatching events should be provided via the dispatcher argument.

Implementation

static Future<TestGesture> down(Offset downLocation, {
  int pointer = 1,
  @required HitTester hitTester,
  @required EventDispatcher dispatcher,
}) async {
  assert(hitTester != null);
  assert(dispatcher != null);
  TestGesture result;
  return TestAsyncUtils.guard<void>(() async {
    // dispatch down event
    final HitTestResult hitTestResult = hitTester(downLocation);
    final TestPointer testPointer = TestPointer(pointer);
    await dispatcher(testPointer.down(downLocation), hitTestResult);

    // create a TestGesture
    result = TestGesture._(dispatcher, hitTestResult, testPointer);
  }).then<TestGesture>((void value) {
    return result;
  }, onError: (dynamic error, StackTrace stack) {
    return Future<TestGesture>.error(error, stack);
  });
}