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 {
@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<Scaffold> 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
......
......@@ -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<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 {
final Key drawerKey = UniqueKey();
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