parent
030eea8617
commit
04bcfe9281
@ -1087,17 +1087,21 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
|
|||||||
if (hasChild(_ScaffoldSlot.body)) {
|
if (hasChild(_ScaffoldSlot.body)) {
|
||||||
double bodyMaxHeight = math.max(0.0, contentBottom - contentTop);
|
double bodyMaxHeight = math.max(0.0, contentBottom - contentTop);
|
||||||
|
|
||||||
if (extendBody) {
|
// When extendBody is true, the body is visible underneath the bottom widgets.
|
||||||
|
// This does not apply when the area is obscured by the device keyboard.
|
||||||
|
if (extendBody && minInsets.bottom <= bottomWidgetsHeight) {
|
||||||
bodyMaxHeight += bottomWidgetsHeight;
|
bodyMaxHeight += bottomWidgetsHeight;
|
||||||
bodyMaxHeight = clampDouble(bodyMaxHeight, 0.0, looseConstraints.maxHeight - contentTop);
|
bodyMaxHeight = clampDouble(bodyMaxHeight, 0.0, looseConstraints.maxHeight - contentTop);
|
||||||
assert(bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop));
|
assert(bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop));
|
||||||
|
} else {
|
||||||
|
bottomWidgetsHeight = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final BoxConstraints bodyConstraints = _BodyBoxConstraints(
|
final BoxConstraints bodyConstraints = _BodyBoxConstraints(
|
||||||
maxWidth: fullWidthConstraints.maxWidth,
|
maxWidth: fullWidthConstraints.maxWidth,
|
||||||
maxHeight: bodyMaxHeight,
|
maxHeight: bodyMaxHeight,
|
||||||
materialBannerHeight: materialBannerSize.height,
|
materialBannerHeight: materialBannerSize.height,
|
||||||
bottomWidgetsHeight: extendBody ? bottomWidgetsHeight : 0.0,
|
bottomWidgetsHeight: bottomWidgetsHeight,
|
||||||
appBarHeight: appBarHeight,
|
appBarHeight: appBarHeight,
|
||||||
);
|
);
|
||||||
layoutChild(_ScaffoldSlot.body, bodyConstraints);
|
layoutChild(_ScaffoldSlot.body, bodyConstraints);
|
||||||
@ -3086,9 +3090,6 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
bottom: _resizeToAvoidBottomInset && MediaQuery.viewInsetsOf(context).bottom != 0.0 ? 0.0 : null,
|
bottom: _resizeToAvoidBottomInset && MediaQuery.viewInsetsOf(context).bottom != 0.0 ? 0.0 : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
// extendBody locked when keyboard is open
|
|
||||||
final bool extendBody = minInsets.bottom <= 0 && widget.extendBody;
|
|
||||||
|
|
||||||
return _ScaffoldScope(
|
return _ScaffoldScope(
|
||||||
hasDrawer: hasDrawer,
|
hasDrawer: hasDrawer,
|
||||||
geometryNotifier: _geometryNotifier,
|
geometryNotifier: _geometryNotifier,
|
||||||
@ -3102,7 +3103,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
},
|
},
|
||||||
child: CustomMultiChildLayout(
|
child: CustomMultiChildLayout(
|
||||||
delegate: _ScaffoldLayout(
|
delegate: _ScaffoldLayout(
|
||||||
extendBody: extendBody,
|
extendBody: widget.extendBody,
|
||||||
extendBodyBehindAppBar: widget.extendBodyBehindAppBar,
|
extendBodyBehindAppBar: widget.extendBodyBehindAppBar,
|
||||||
minInsets: minInsets,
|
minInsets: minInsets,
|
||||||
minViewPadding: minViewPadding,
|
minViewPadding: minViewPadding,
|
||||||
|
@ -3418,6 +3418,36 @@ void main() {
|
|||||||
));
|
));
|
||||||
expect(scaffoldMaterial.color, theme.colorScheme.surface);
|
expect(scaffoldMaterial.color, theme.colorScheme.surface);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Body height remains Scaffold height when keyboard is smaller than bottomNavigationBar and extendBody is true', (WidgetTester tester) async {
|
||||||
|
final Key bodyKey = UniqueKey();
|
||||||
|
Widget buildFrame({double keyboardHeight = 0}) {
|
||||||
|
return MaterialApp(
|
||||||
|
home: Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return MediaQuery(
|
||||||
|
data: MediaQuery.of(context).copyWith(
|
||||||
|
viewInsets: EdgeInsets.only(bottom: keyboardHeight),
|
||||||
|
),
|
||||||
|
child: Scaffold(
|
||||||
|
extendBody: true,
|
||||||
|
body: SizedBox.expand(key: bodyKey),
|
||||||
|
bottomNavigationBar:const SizedBox(height: 100),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await tester.pumpWidget(buildFrame());
|
||||||
|
expect(tester.getSize(find.byKey(bodyKey)).height, 600);
|
||||||
|
|
||||||
|
await tester.pumpWidget(buildFrame(keyboardHeight: 100));
|
||||||
|
expect(tester.getSize(find.byKey(bodyKey)).height, 600);
|
||||||
|
|
||||||
|
await tester.pumpWidget(buildFrame(keyboardHeight: 200));
|
||||||
|
expect(tester.getSize(find.byKey(bodyKey)).height, 400);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GeometryListener extends StatefulWidget {
|
class _GeometryListener extends StatefulWidget {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user