@@ -12,6 +12,39 @@ import 'package:flutter_test/flutter_test.dart';
1212import '../widgets/semantics_tester.dart' ;
1313
1414void main () {
15+ // Regression test for https://github.com/flutter/flutter/issues/103741
16+ testWidgets ('extendBodyBehindAppBar change should not cause the body widget lose state' , (WidgetTester tester) async {
17+ final ScrollController controller = ScrollController ();
18+ Widget buildFrame ({required bool extendBodyBehindAppBar}) {
19+ return MediaQuery (
20+ data: const MediaQueryData (),
21+ child: Directionality (
22+ textDirection: TextDirection .ltr,
23+ child: Scaffold (
24+ extendBodyBehindAppBar: extendBodyBehindAppBar,
25+ resizeToAvoidBottomInset: false ,
26+ body: SingleChildScrollView (
27+ controller: controller,
28+ child: const FlutterLogo (
29+ size: 1107 ,
30+ ),
31+ ),
32+ ),
33+ ),
34+ );
35+ }
36+
37+ await tester.pumpWidget (buildFrame (extendBodyBehindAppBar: true ));
38+ expect (controller.position.pixels, 0.0 );
39+
40+ controller.jumpTo (100.0 );
41+ await tester.pump ();
42+ expect (controller.position.pixels, 100.0 );
43+
44+ await tester.pumpWidget (buildFrame (extendBodyBehindAppBar: false ));
45+ expect (controller.position.pixels, 100.0 );
46+ });
47+
1548 testWidgets ('Scaffold drawer callback test' , (WidgetTester tester) async {
1649 bool isDrawerOpen = false ;
1750 bool isEndDrawerOpen = false ;
@@ -2402,6 +2435,7 @@ void main() {
24022435 ' ancestor was:\n '
24032436 ' Builder\n '
24042437 ' The ancestors of this widget were:\n '
2438+ ' KeyedSubtree-[GlobalKey#00000]\n '
24052439 ' _BodyBuilder\n '
24062440 ' MediaQuery\n '
24072441 ' LayoutId-[<_ScaffoldSlot.body>]\n '
0 commit comments