Skip to content

Commit b825d18

Browse files
Add dedicated methods for dragging up and down
1 parent a4e6831 commit b825d18

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/src/scrollbar.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,30 @@ import 'package:flutter_test/flutter_test.dart';
66

77
/// Simulates the user interacting with a Scrollbar.
88
extension ScrollbarInteractions on WidgetTester {
9+
/// Drag the scrollbar down by [delta] pixels.
10+
///
11+
/// By default, this method expects a single [Scrollbar] in the widget tree and
12+
/// finds it `byType`. To specify one [Scrollbar] among many, pass a [finder].
13+
Future<void> dragScrollbarDown(double delta, [Finder? finder]) async {
14+
await _dragScrollbar(delta, finder);
15+
}
16+
17+
/// Drag the scrollbar up by [delta] pixels.
18+
///
19+
/// By default, this method expects a single [Scrollbar] in the widget tree and
20+
/// finds it `byType`. To specify one [Scrollbar] among many, pass a [finder].
21+
Future<void> dragScrollbarUp(double delta, [Finder? finder]) async {
22+
await _dragScrollbar(-delta, finder);
23+
}
24+
925
/// Drag the scrollbar by [delta] pixels.
1026
///
1127
/// A positive [delta] scrolls down or right, depending on the scrollbar's orientation,
1228
/// and a negative [delta] scrolls up or left.
1329
///
1430
/// By default, this method expects a single [Scrollbar] in the widget tree and
1531
/// finds it `byType`. To specify one [Scrollbar] among many, pass a [finder].
16-
Future<void> dragScrollbar(double delta, [Finder? finder]) async {
32+
Future<void> _dragScrollbar(double delta, [Finder? finder]) async {
1733
// Find where the scrollbar's thumb sits.
1834
final thumbRect = _findThumbRect(finder ?? find.byType(Scrollbar));
1935
final thumbOffset = thumbRect.center;

0 commit comments

Comments
 (0)