scrollable_helpers_test.dart 21.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

final LogicalKeyboardKey modifierKey = defaultTargetPlatform == TargetPlatform.macOS
  ? LogicalKeyboardKey.metaLeft
  : LogicalKeyboardKey.controlLeft;

void main() {
15 16
  group('ScrollableDetails', (){
    test('copyWith / == / hashCode', () {
17 18
      final ScrollController controller = ScrollController();
      addTearDown(controller.dispose);
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
      final ScrollableDetails details = ScrollableDetails(
        direction: AxisDirection.down,
        controller: controller,
        physics: const AlwaysScrollableScrollPhysics(),
        decorationClipBehavior: Clip.hardEdge,
      );
      ScrollableDetails copiedDetails = details.copyWith();
      expect(details, copiedDetails);
      expect(details.hashCode, copiedDetails.hashCode);

      copiedDetails = details.copyWith(
        direction: AxisDirection.left,
        physics: const ClampingScrollPhysics(),
        decorationClipBehavior: Clip.none,
      );
      expect(
        copiedDetails,
        ScrollableDetails(
          direction: AxisDirection.left,
          controller: controller,
          physics: const ClampingScrollPhysics(),
          decorationClipBehavior: Clip.none,
        ),
      );
    });

    test('toString', (){
46 47
      final ScrollController controller = ScrollController();
      addTearDown(controller.dispose);
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
      const ScrollableDetails bareDetails = ScrollableDetails(
        direction: AxisDirection.right,
      );
      expect(
        bareDetails.toString(),
        equalsIgnoringHashCodes(
          'ScrollableDetails#00000(axisDirection: AxisDirection.right)'
        ),
      );
      final ScrollableDetails fullDetails = ScrollableDetails(
        direction: AxisDirection.down,
        controller: controller,
        physics: const AlwaysScrollableScrollPhysics(),
        decorationClipBehavior: Clip.hardEdge,
      );
      expect(
        fullDetails.toString(),
        equalsIgnoringHashCodes(
          'ScrollableDetails#00000('
          'axisDirection: AxisDirection.down, '
          'scroll controller: ScrollController#00000(no clients), '
          'scroll physics: AlwaysScrollableScrollPhysics, '
          'decorationClipBehavior: Clip.hardEdge)'
        ),
      );
    });

    test('deprecated clipBehavior is backwards compatible', (){
      const ScrollableDetails deprecatedClip = ScrollableDetails(
        direction: AxisDirection.right,
        clipBehavior: Clip.hardEdge,
      );
      expect(deprecatedClip.clipBehavior, Clip.hardEdge);
      expect(deprecatedClip.decorationClipBehavior, Clip.hardEdge);

      const ScrollableDetails newClip = ScrollableDetails(
        direction: AxisDirection.right,
        decorationClipBehavior: Clip.hardEdge,
      );
      expect(newClip.clipBehavior, Clip.hardEdge);
      expect(newClip.decorationClipBehavior, Clip.hardEdge);
    });
  });

92
  testWidgets("Keyboard scrolling doesn't happen if scroll physics are set to NeverScrollableScrollPhysics", (WidgetTester tester) async {
93
    final ScrollController controller = ScrollController();
94
    addTearDown(controller.dispose);
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
    await tester.pumpWidget(
      MaterialApp(
        theme: ThemeData(platform: TargetPlatform.fuchsia),
        home: CustomScrollView(
          controller: controller,
          physics: const NeverScrollableScrollPhysics(),
          slivers: List<Widget>.generate(
            20,
            (int index) {
              return SliverToBoxAdapter(
                child: Focus(
                  autofocus: index == 0,
                  child: SizedBox(
                    key: ValueKey<String>('Box $index'),
                    height: 50.0,
                  ),
                ),
              );
            },
          ),
        ),
      ),
    );

    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
    await tester.sendKeyDownEvent(modifierKey);
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
    await tester.sendKeyUpEvent(modifierKey);
    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
    await tester.sendKeyDownEvent(modifierKey);
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
    await tester.sendKeyUpEvent(modifierKey);
    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
    await tester.sendKeyEvent(LogicalKeyboardKey.pageDown);
    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
    await tester.sendKeyEvent(LogicalKeyboardKey.pageUp);
    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
  }, variant: KeySimulatorTransitModeVariant.all());

159
  testWidgets('Vertical scrollables are scrolled when activated via keyboard.', (WidgetTester tester) async {
160
    final ScrollController controller = ScrollController();
161
    addTearDown(controller.dispose);
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
    await tester.pumpWidget(
      MaterialApp(
        theme: ThemeData(platform: TargetPlatform.fuchsia),
        home: CustomScrollView(
          controller: controller,
          slivers: List<Widget>.generate(
            20,
            (int index) {
              return SliverToBoxAdapter(
                child: Focus(
                  autofocus: index == 0,
                  child: SizedBox(
                    key: ValueKey<String>('Box $index'),
                    height: 50.0,
                  ),
                ),
              );
            },
          ),
        ),
      ),
    );

    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
    // We exclude the modifier keys here for web testing since default web shortcuts
    // do not use a modifier key with arrow keys for ScrollActions.
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, -50.0, 800.0, 0.0)),
    );
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
    await tester.sendKeyEvent(LogicalKeyboardKey.pageDown);
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, -400.0, 800.0, -350.0)),
    );
    await tester.sendKeyEvent(LogicalKeyboardKey.pageUp);
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0)),
    );
  }, variant: KeySimulatorTransitModeVariant.all());

231
  testWidgets('Horizontal scrollables are scrolled when activated via keyboard.', (WidgetTester tester) async {
232
    final ScrollController controller = ScrollController();
233
    addTearDown(controller.dispose);
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
    await tester.pumpWidget(
      MaterialApp(
        theme: ThemeData(platform: TargetPlatform.fuchsia),
        home: CustomScrollView(
          controller: controller,
          scrollDirection: Axis.horizontal,
          slivers: List<Widget>.generate(
            20,
            (int index) {
              return SliverToBoxAdapter(
                child: Focus(
                  autofocus: index == 0,
                  child: SizedBox(
                    key: ValueKey<String>('Box $index'),
                    width: 50.0,
                  ),
                ),
              );
            },
          ),
        ),
      ),
    );

    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 50.0, 600.0)),
    );
    // We exclude the modifier keys here for web testing since default web shortcuts
    // do not use a modifier key with arrow keys for ScrollActions.
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(-50.0, 0.0, 0.0, 600.0)),
    );
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 50.0, 600.0)),
    );
  }, variant: KeySimulatorTransitModeVariant.all());

292
  testWidgets('Horizontal scrollables are scrolled the correct direction in RTL locales.', (WidgetTester tester) async {
293
    final ScrollController controller = ScrollController();
294
    addTearDown(controller.dispose);
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
    await tester.pumpWidget(
      MaterialApp(
        theme: ThemeData(platform: TargetPlatform.fuchsia),
        home: Directionality(
          textDirection: TextDirection.rtl,
          child: CustomScrollView(
            controller: controller,
            scrollDirection: Axis.horizontal,
            slivers: List<Widget>.generate(
              20,
                  (int index) {
                return SliverToBoxAdapter(
                  child: Focus(
                    autofocus: index == 0,
                    child: SizedBox(
                      key: ValueKey<String>('Box $index'),
                      width: 50.0,
                    ),
                  ),
                );
              },
            ),
          ),
        ),
      ),
    );

    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(750.0, 0.0, 800.0, 600.0)),
    );
    // We exclude the modifier keys here for web testing since default web shortcuts
    // do not use a modifier key with arrow keys for ScrollActions.
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(800.0, 0.0, 850.0, 600.0)),
    );
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(750.0, 0.0, 800.0, 600.0)),
    );
  }, variant: KeySimulatorTransitModeVariant.all());

356
  testWidgets('Reversed vertical scrollables are scrolled when activated via keyboard.', (WidgetTester tester) async {
357
    final ScrollController controller = ScrollController();
358
    addTearDown(controller.dispose);
359
    final FocusNode focusNode = FocusNode(debugLabel: 'SizedBox');
360
    addTearDown(focusNode.dispose);
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
    await tester.pumpWidget(
      MaterialApp(
        theme: ThemeData(platform: TargetPlatform.fuchsia),
        home: CustomScrollView(
          controller: controller,
          reverse: true,
          slivers: List<Widget>.generate(
            20,
            (int index) {
              return SliverToBoxAdapter(
                child: Focus(
                  focusNode: focusNode,
                  child: SizedBox(
                    key: ValueKey<String>('Box $index'),
                    height: 50.0,
                  ),
                ),
              );
            },
          ),
        ),
      ),
    );

    focusNode.requestFocus();
    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 550.0, 800.0, 600.0)),
    );
    // We exclude the modifier keys here for web testing since default web shortcuts
    // do not use a modifier key with arrow keys for ScrollActions.
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 600.0, 800.0, 650.0)),
    );
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 550.0, 800.0, 600.0)),
    );
    await tester.sendKeyEvent(LogicalKeyboardKey.pageUp);
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 950.0, 800.0, 1000.0)),
    );
    await tester.sendKeyEvent(LogicalKeyboardKey.pageDown);
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 550.0, 800.0, 600.0)),
    );
  }, variant: KeySimulatorTransitModeVariant.all());

432
  testWidgets('Reversed horizontal scrollables are scrolled when activated via keyboard.', (WidgetTester tester) async {
433
    final ScrollController controller = ScrollController();
434
    addTearDown(controller.dispose);
435
    final FocusNode focusNode = FocusNode(debugLabel: 'SizedBox');
436
    addTearDown(focusNode.dispose);
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
    await tester.pumpWidget(
      MaterialApp(
        theme: ThemeData(platform: TargetPlatform.fuchsia),
        home: CustomScrollView(
          controller: controller,
          scrollDirection: Axis.horizontal,
          reverse: true,
          slivers: List<Widget>.generate(
            20,
            (int index) {
              return SliverToBoxAdapter(
                child: Focus(
                  focusNode: focusNode,
                  child: SizedBox(
                    key: ValueKey<String>('Box $index'),
                    width: 50.0,
                  ),
                ),
              );
            },
          ),
        ),
      ),
    );

    focusNode.requestFocus();
    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(750.0, 0.0, 800.0, 600.00)),
    );
    // We exclude the modifier keys here for web testing since default web shortcuts
    // do not use a modifier key with arrow keys for ScrollActions.
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Box 0'), skipOffstage: false)),
      equals(const Rect.fromLTRB(800.0, 0.0, 850.0, 600.0)),
    );
    if (!kIsWeb) {
      await tester.sendKeyDownEvent(modifierKey);
    }
    await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
    if (!kIsWeb) {
      await tester.sendKeyUpEvent(modifierKey);
    }
    await tester.pumpAndSettle();
  }, variant: KeySimulatorTransitModeVariant.all());

493
  testWidgets('Custom scrollables with a center sliver are scrolled when activated via keyboard.', (WidgetTester tester) async {
494
    final ScrollController controller = ScrollController();
495
    addTearDown(controller.dispose);
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
    final List<String> items = List<String>.generate(20, (int index) => 'Item $index');
    await tester.pumpWidget(
      MaterialApp(
        theme: ThemeData(platform: TargetPlatform.fuchsia),
        home: CustomScrollView(
          controller: controller,
          center: const ValueKey<String>('Center'),
          slivers: items.map<Widget>(
            (String item) {
              return SliverToBoxAdapter(
                key: item == 'Item 10' ? const ValueKey<String>('Center') : null,
                child: Focus(
                  autofocus: item == 'Item 10',
                  child: Container(
                    key: ValueKey<String>(item),
                    alignment: Alignment.center,
                    height: 100,
                    child: Text(item),
                  ),
                ),
              );
            },
          ).toList(),
        ),
      ),
    );

    await tester.pumpAndSettle();
    expect(controller.position.pixels, equals(0.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Item 10'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 0.0, 800.0, 100.0)),
    );
    for (int i = 0; i < 10; ++i) {
      // We exclude the modifier keys here for web testing since default web shortcuts
      // do not use a modifier key with arrow keys for ScrollActions.
      if (!kIsWeb) {
        await tester.sendKeyDownEvent(modifierKey);
      }
      await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
      if (!kIsWeb) {
        await tester.sendKeyUpEvent(modifierKey);
      }
      await tester.pumpAndSettle();
    }
    // Starts at #10 already, so doesn't work out to 500.0 because it hits bottom.
    expect(controller.position.pixels, equals(400.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Item 10'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, -400.0, 800.0, -300.0)),
    );
    for (int i = 0; i < 10; ++i) {
      if (!kIsWeb) {
        await tester.sendKeyDownEvent(modifierKey);
      }
      await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
      if (!kIsWeb) {
        await tester.sendKeyUpEvent(modifierKey);
      }
      await tester.pumpAndSettle();
    }
    // Goes up two past "center" where it started, so negative.
    expect(controller.position.pixels, equals(-100.0));
    expect(
      tester.getRect(find.byKey(const ValueKey<String>('Item 10'), skipOffstage: false)),
      equals(const Rect.fromLTRB(0.0, 100.0, 800.0, 200.0)),
    );
  }, variant: KeySimulatorTransitModeVariant.all());
564

565
  testWidgets('Can scroll using intents only', (WidgetTester tester) async {
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
    await tester.pumpWidget(
      MaterialApp(
        home: ListView(
          children: const <Widget>[
            SizedBox(height: 600.0, child: Text('The cow as white as milk')),
            SizedBox(height: 600.0, child: Text('The cape as red as blood')),
            SizedBox(height: 600.0, child: Text('The hair as yellow as corn')),
          ],
        ),
      ),
    );
    expect(find.text('The cow as white as milk'), findsOneWidget);
    expect(find.text('The cape as red as blood'), findsNothing);
    expect(find.text('The hair as yellow as corn'), findsNothing);
    Actions.invoke(tester.element(find.byType(SliverList)), const ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page));
    await tester.pump(); // start scroll
    await tester.pump(const Duration(milliseconds: 1000)); // end scroll
    expect(find.text('The cow as white as milk'), findsOneWidget);
    expect(find.text('The cape as red as blood'), findsOneWidget);
    expect(find.text('The hair as yellow as corn'), findsNothing);
    Actions.invoke(tester.element(find.byType(SliverList)), const ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page));
    await tester.pump(); // start scroll
    await tester.pump(const Duration(milliseconds: 1000)); // end scroll
    expect(find.text('The cow as white as milk'), findsNothing);
    expect(find.text('The cape as red as blood'), findsOneWidget);
    expect(find.text('The hair as yellow as corn'), findsOneWidget);
  });
593
}