@@ -357,4 +357,57 @@ void main() {
357
357
await tester.pumpAndSettle ();
358
358
expect (getHeaderHeight (), 200 );
359
359
});
360
+
361
+ testWidgets ('SliverResizingHeader maxScrollObstructionExtent' , (WidgetTester tester) async {
362
+ await tester.pumpWidget (
363
+ MaterialApp (
364
+ home: Scaffold (
365
+ body: NestedScrollView (
366
+ headerSliverBuilder:
367
+ (BuildContext context, _) => < Widget > [
368
+ SliverOverlapAbsorber (
369
+ handle: NestedScrollView .sliverOverlapAbsorberHandleFor (context),
370
+ sliver: const SliverResizingHeader (
371
+ minExtentPrototype: SizedBox (height: 100 ),
372
+ maxExtentPrototype: SizedBox (height: 300 ),
373
+ child: SizedBox .expand (child: Text ('header' )),
374
+ ),
375
+ ),
376
+ ],
377
+ body: Builder (
378
+ builder:
379
+ (BuildContext context) => CustomScrollView (
380
+ slivers: < Widget > [
381
+ SliverOverlapInjector (
382
+ handle: NestedScrollView .sliverOverlapAbsorberHandleFor (context),
383
+ ),
384
+ SliverList (
385
+ delegate: SliverChildBuilderDelegate (
386
+ (BuildContext context, int index) =>
387
+ SizedBox (height: 50 , child: Text ('$index ' )),
388
+ childCount: 100 ,
389
+ ),
390
+ ),
391
+ ],
392
+ ),
393
+ ),
394
+ ),
395
+ ),
396
+ ),
397
+ );
398
+
399
+ double getHeaderHeight () => tester.getSize (find.text ('header' )).height;
400
+
401
+ expect (getHeaderHeight (), 300 );
402
+
403
+ // After scrolling down 150px, the header height becomes 150px
404
+ await tester.drag (find.byType (NestedScrollView ), const Offset (0 , - 150 ));
405
+ await tester.pumpAndSettle ();
406
+ expect (getHeaderHeight (), 150 );
407
+
408
+ // After scrolling down an additional 150px, the header height becomes 100px
409
+ await tester.drag (find.byType (NestedScrollView ), const Offset (0 , - 150 ));
410
+ await tester.pumpAndSettle ();
411
+ expect (getHeaderHeight (), 100 );
412
+ });
360
413
}
0 commit comments