Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylus Gestures Not Recognized in PageListViewportGestures Widget #57

Open
Tsames opened this issue Dec 15, 2023 · 0 comments
Open

Stylus Gestures Not Recognized in PageListViewportGestures Widget #57

Tsames opened this issue Dec 15, 2023 · 0 comments

Comments

@Tsames
Copy link

Tsames commented Dec 15, 2023

The widget constructor for PageListViewportGestures accepts an argument called deviceKind. We expect that when stylus is added as a device, the user wil be able to use it to scroll. However, even after providing stylus as one of the device kinds the widget does not recognize gestures made with a stylus.

To confirm our findings, we created a test called operates as a panning device. In it, we fling with a stylus, expecting the velocity to update, but it never does.

    //Add stylus to PageListViewPortGestures
    final deviceKind = {
        PointerDeviceKind.mouse,
        PointerDeviceKind.trackpad,
        PointerDeviceKind.touch,
        PointerDeviceKind.stylus,
    };
    await _pumpPageListViewport(widgetTester, controller: controller, pointerDevices: deviceKind);

    Offset? latestVelocity;
    controller.addListener(() {
    latestVelocity = controller.velocity;
    });

    // Fling up with stylus
    await widgetTester.fling(find.byType(Scaffold), const Offset(0, -500), 4000,
        deviceKind: PointerDeviceKind.stylus);

    // The viewport is moving after fling
    await widgetTester.pump();
    expect(latestVelocity, isNotNull);

It looks like there is a slight issue with the control flow, intentionally preventing gestures with a stylus.


Despite stylus not being fully supported as a device, we observe that an already scrolling viewport can in practice be stopped with a stylus. Reproducing it in a test, we observe that on stylus down the viewport does not halt immediately (after a pump). Here is the full test. However, we notice that if we pump four times, the viewport action stops.

    // Fling up, to scroll down, and run a panning simulation.
    await widgetTester.fling(find.byType(Scaffold), const Offset(0, -500), 4000);
    // The viewport is moving
    await widgetTester.pump();
    expect(latestVelocity == Offset.zero, false);

    await widgetTester.startGesture(const Offset(0, 0), kind: PointerDeviceKind.stylus);
    // Pumping one frame does not suffice to propagate the stylus gesture
    // and stop the scrolling simulation, so we're using a pumping duration.
    await widgetTester.pump();

    expect(latestVelocity == Offset.zero, true); // Fails

It looks like stopMomentum() is not properly stopping the viewport controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant