diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 56260cfe88..a18184bd3b 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -1144,12 +1144,13 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { @override bool shouldRelayout(_ScaffoldLayout oldDelegate) { return oldDelegate.minInsets != minInsets - || oldDelegate.textDirection != textDirection - || oldDelegate.floatingActionButtonMoveAnimationProgress != floatingActionButtonMoveAnimationProgress - || oldDelegate.previousFloatingActionButtonLocation != previousFloatingActionButtonLocation - || oldDelegate.currentFloatingActionButtonLocation != currentFloatingActionButtonLocation - || oldDelegate.extendBody != extendBody - || oldDelegate.extendBodyBehindAppBar != extendBodyBehindAppBar; + || oldDelegate.minViewPadding != minViewPadding + || oldDelegate.textDirection != textDirection + || oldDelegate.floatingActionButtonMoveAnimationProgress != floatingActionButtonMoveAnimationProgress + || oldDelegate.previousFloatingActionButtonLocation != previousFloatingActionButtonLocation + || oldDelegate.currentFloatingActionButtonLocation != currentFloatingActionButtonLocation + || oldDelegate.extendBody != extendBody + || oldDelegate.extendBodyBehindAppBar != extendBodyBehindAppBar; } } @@ -2861,7 +2862,7 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto // The minimum viewPadding for interactive elements positioned by the // Scaffold to keep within safe interactive areas. final EdgeInsets minViewPadding = mediaQuery.viewPadding.copyWith( - bottom: _resizeToAvoidBottomInset && mediaQuery.viewInsets.bottom != 0.0 ? 0.0 : null, + bottom: _resizeToAvoidBottomInset && mediaQuery.viewInsets.bottom != 0.0 ? 0.0 : null, ); // extendBody locked when keyboard is open diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index f07b452977..219fdf0099 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -276,12 +276,17 @@ void main() { await tester.pumpWidget( MediaQuery( data: const MediaQueryData( - padding: EdgeInsets.only(bottom: 20.0), + viewPadding: EdgeInsets.only(bottom: 20.0), ), child: child, ), ); final Offset initialPoint = tester.getCenter(find.byType(Placeholder)); + expect( + tester.getBottomLeft(find.byType(Placeholder)).dy, + moreOrLessEquals(600.0 - 20.0 - kFloatingActionButtonMargin) + ); + // Consume bottom padding - as if by the keyboard opening await tester.pumpWidget( MediaQuery( @@ -296,6 +301,37 @@ void main() { expect(initialPoint, finalPoint); }); + testWidgets('viewPadding change should trigger _ScaffoldLayout re-layout', (WidgetTester tester) async { + Widget buildFrame(EdgeInsets viewPadding) { + return MediaQuery( + data: MediaQueryData( + viewPadding: viewPadding, + ), + child: Directionality( + textDirection: TextDirection.ltr, + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container(), + floatingActionButton: const Placeholder(), + ), + ), + ); + } + + await tester.pumpWidget(buildFrame(const EdgeInsets.only(bottom: 300))); + + final RenderBox renderBox = tester.renderObject(find.byType(CustomMultiChildLayout)); + expect(renderBox.debugNeedsLayout, false); + + await tester.pumpWidget( + buildFrame(const EdgeInsets.only(bottom: 400)), + null, + EnginePhase.build, + ); + + expect(renderBox.debugNeedsLayout, true); + }); + testWidgets('Drawer scrolling', (WidgetTester tester) async { final Key drawerKey = UniqueKey(); const double appBarHeight = 256.0;