|
1 | 1 | import 'package:checks/checks.dart';
|
| 2 | +import 'package:flutter/foundation.dart'; |
2 | 3 | // ignore: undefined_hidden_name // anticipates https://github.com/flutter/flutter/pull/164818
|
3 | 4 | import 'package:flutter/rendering.dart' hide SliverPaintOrder;
|
4 | 5 | // ignore: undefined_hidden_name // anticipates https://github.com/flutter/flutter/pull/164818
|
@@ -376,6 +377,46 @@ void main() {
|
376 | 377 | // … without moving any farther.
|
377 | 378 | check(position.extentAfter).equals(0);
|
378 | 379 | });
|
| 380 | + |
| 381 | + testWidgets('starting from overscroll, just drift', (tester) async { |
| 382 | + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; |
| 383 | + await prepare(tester, topHeight: 400, bottomHeight: 400); |
| 384 | + |
| 385 | + // Drag into overscroll. |
| 386 | + await tester.drag(findBottom, Offset(0, -100)); |
| 387 | + await tester.pump(); |
| 388 | + final offset1 = position.pixels - position.maxScrollExtent; |
| 389 | + check(offset1).isGreaterThan(100 / 2); |
| 390 | + check(position.activity).isA<BallisticScrollActivity>(); |
| 391 | + |
| 392 | + // Start drifting back into range. |
| 393 | + await tester.pump(Duration(milliseconds: 10)); |
| 394 | + final offset2 = position.pixels - position.maxScrollExtent; |
| 395 | + check(offset2)..isGreaterThan(0.0)..isLessThan(offset1); |
| 396 | + check(position.activity).isA<BallisticScrollActivity>() |
| 397 | + .velocity.isLessThan(0); |
| 398 | + |
| 399 | + // Invoke `scrollToEnd`. The motion should stop… |
| 400 | + position.scrollToEnd(); |
| 401 | + await tester.pump(); |
| 402 | + check(position.pixels - position.maxScrollExtent).equals(offset2); |
| 403 | + check(position.activity).isA<BallisticScrollActivity>() |
| 404 | + .velocity.equals(0); |
| 405 | + |
| 406 | + // … and resume drifting from there… |
| 407 | + await tester.pump(Duration(milliseconds: 10)); |
| 408 | + final offset3 = position.pixels - position.maxScrollExtent; |
| 409 | + check(offset3)..isGreaterThan(0.0)..isLessThan(offset2); |
| 410 | + check(position.activity).isA<BallisticScrollActivity>() |
| 411 | + .velocity.isLessThan(0); |
| 412 | + |
| 413 | + // … to eventually return to being in range. |
| 414 | + await tester.pump(Duration(seconds: 1)); |
| 415 | + check(position.pixels - position.maxScrollExtent).equals(0); |
| 416 | + check(position.activity).isA<IdleScrollActivity>(); |
| 417 | + |
| 418 | + debugDefaultTargetPlatformOverride = null; |
| 419 | + }); |
379 | 420 | });
|
380 | 421 | });
|
381 | 422 | }
|
|
0 commit comments