import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart'; void main() { testWidgets('reserved header gives scrolling text an independent viewport', ( tester, ) async { final scroll = ScrollController(); addTearDown(scroll.dispose); double? topPadding; await tester.pumpWidget( MaterialApp( home: Scaffold( body: SegmentedBarOverlay( reserveSpace: true, bar: const SizedBox(key: Key('header'), height: 80), child: Builder( builder: (context) { topPadding = MediaQuery.paddingOf(context).top; return ListView( controller: scroll, children: List.generate( 50, (i) => ListTile(title: Text('Line $i')), ), ); }, ), ), ), ), ); expect( tester.getTopLeft(find.byType(ListView)).dy, tester.getBottomLeft(find.byKey(const Key('header'))).dy, ); expect(topPadding, 0); await tester.drag(find.byType(ListView), const Offset(0, -300)); await tester.pumpAndSettle(); expect(scroll.offset, greaterThan(0)); expect(tester.getTopLeft(find.byType(ListView)).dy, 80); expect(tester.takeException(), isNull); }); }