-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi,
from 0.18.0 changelog
Breaking: Add act.dragUntilVisible() now moves the target in the center of the viewport (one additional drag). parameter moveStep is now optional, default to half the scrollable size. The direction can be controlled with bool toStart.
but there is another breaking change for dragUntilVisible. You can't put Scrollable selector as dragTarget.
If I'm not wrong the sample code from readme won't work
await act.dragUntilVisible(
dragStart: spot<LongListScreen>().spot<Scrollable>(),
dragTarget: spotText('Item 32'),
moveStep: const Offset(0, -100),
);because of
// Take the closest Scrollable above the dragStart widget. This is the
// widget which makes a widget scrollable. It must always exist.
final WidgetSelector<Scrollable> scrollable =
spot<Scrollable>().withChild(dragStart).last();I think there are two ways to achieve "dragUntilVisible"
"What should I scroll?" and "Where should I put my finger to start dragging?"
and both are fine. but current method covers only the latter.
Expected behaviour:
Be able to scroll to specific element on some scrollable selector.
Possible solutions:
- another method
scrollUntilVisible()which takes scrollable selector (similar to flutter_test methods)?
Future<void> scrollUntilVisible({
required WidgetSelector<Scrollable> scrollable,
required WidgetSelector<Widget> dragTarget,
Offset? moveStep,
int maxIteration = 50,
Duration duration = const Duration(milliseconds: 50),
bool toStart = false,
WidgetSelector<Scrollable>? fallbackScrollableSelector,
});- dragUntiVisible could work for both cases with:
...
final WidgetSelector<Scrollable> scrollable = switch (dragStart) {
WidgetSelector<Scrollable>() => dragStart,
_ => spot<Scrollable>().withChild(dragStart).last(),
};
...What do you think?
Thank you a lot!