Unverified Commit 0a88d820 authored by xubaolin's avatar xubaolin Committed by GitHub

fix a _ScaffoldLayout delegate update bug (#104954)

parent 80bfc8f3
...@@ -1144,12 +1144,13 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { ...@@ -1144,12 +1144,13 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
@override @override
bool shouldRelayout(_ScaffoldLayout oldDelegate) { bool shouldRelayout(_ScaffoldLayout oldDelegate) {
return oldDelegate.minInsets != minInsets return oldDelegate.minInsets != minInsets
|| oldDelegate.textDirection != textDirection || oldDelegate.minViewPadding != minViewPadding
|| oldDelegate.floatingActionButtonMoveAnimationProgress != floatingActionButtonMoveAnimationProgress || oldDelegate.textDirection != textDirection
|| oldDelegate.previousFloatingActionButtonLocation != previousFloatingActionButtonLocation || oldDelegate.floatingActionButtonMoveAnimationProgress != floatingActionButtonMoveAnimationProgress
|| oldDelegate.currentFloatingActionButtonLocation != currentFloatingActionButtonLocation || oldDelegate.previousFloatingActionButtonLocation != previousFloatingActionButtonLocation
|| oldDelegate.extendBody != extendBody || oldDelegate.currentFloatingActionButtonLocation != currentFloatingActionButtonLocation
|| oldDelegate.extendBodyBehindAppBar != extendBodyBehindAppBar; || oldDelegate.extendBody != extendBody
|| oldDelegate.extendBodyBehindAppBar != extendBodyBehindAppBar;
} }
} }
...@@ -2861,7 +2862,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto ...@@ -2861,7 +2862,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
// The minimum viewPadding for interactive elements positioned by the // The minimum viewPadding for interactive elements positioned by the
// Scaffold to keep within safe interactive areas. // Scaffold to keep within safe interactive areas.
final EdgeInsets minViewPadding = mediaQuery.viewPadding.copyWith( 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 // extendBody locked when keyboard is open
......
...@@ -276,12 +276,17 @@ void main() { ...@@ -276,12 +276,17 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
MediaQuery( MediaQuery(
data: const MediaQueryData( data: const MediaQueryData(
padding: EdgeInsets.only(bottom: 20.0), viewPadding: EdgeInsets.only(bottom: 20.0),
), ),
child: child, child: child,
), ),
); );
final Offset initialPoint = tester.getCenter(find.byType(Placeholder)); 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 // Consume bottom padding - as if by the keyboard opening
await tester.pumpWidget( await tester.pumpWidget(
MediaQuery( MediaQuery(
...@@ -296,6 +301,37 @@ void main() { ...@@ -296,6 +301,37 @@ void main() {
expect(initialPoint, finalPoint); 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<RenderBox>(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 { testWidgets('Drawer scrolling', (WidgetTester tester) async {
final Key drawerKey = UniqueKey(); final Key drawerKey = UniqueKey();
const double appBarHeight = 256.0; const double appBarHeight = 256.0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment