Repository navigation
Add extendBody parameter to Scaffold, body MediaQuery reflects BAB height - #27973
Conversation
|
@HansMuller Let's make sure Igor Katsuba is in the AUTHORS file as part of this. |
| bool operator ==(dynamic other) { | ||
| if (super != other) | ||
| return false; | ||
| if (other is! _BodyBoxConstraints) |
There was a problem hiding this comment.
you can make this an assert -- the superclass should check the runtimeType is equals.
If the superclass doesn't do that (and uses is instead), then we should change the superclass to check runtimeType.
There was a problem hiding this comment.
I've done that for BoxConstraints. Many of our 'operator ==' overloads use is rather than comparing runtimeType, perhaps we should make convert them all in a separate PR?
| ); | ||
|
|
||
| // extendBody locked when keyboard is open | ||
| final bool _extendBody = minInsets.bottom > 0 ? false : widget.extendBody; |
There was a problem hiding this comment.
i wonder if this is really correct in all cases...
There was a problem hiding this comment.
The value of minInsets.bottom is just the media query's value of viewInsets.bottom (unless resizeToAvoidBottomInsets is false). It doesn't guarantee that the keyboard is up however if someone were to configure a MediaQuery that way we'd react the same was as if the keyboard is up.
I think this is OK, albeit complicated: we don't extend the bottom of the body if resizeToAvoidBottomInsets is true (the default) and viewInsets.bottom is non-zero.
|
Hi, do you know when it will be release ? in which version of flutter ? |
|
@vAugagneur, Unfortunately, it just missed the cutoff for the latest stable release. It is currently available in the dev branch. If you want to stay on the stable branch, it will be in the 1.3 release of stable. |
Fixes #17555
This PR is based on #25654 which was contributed by @IKatsuba.
If
Scaffold.extendedBodyis true then the Scaffold's body extends to the bottom of the Scaffold, instead of only extending to the top ofScaffold.bottomNavigationBar. This ensures that the scaffold's body will appear behind a non-rectangular or sem-transparent bottom navigation bar of behind the Scaffold'spersistentFooterButtons.Scaffold.extendedBodyis false by default.This change corrects a long standing problem with "notched" bottom navigation bars.
Before
After
If
Scaffold.extendedBodyis true and the bottom navigation bar is specified then a MediaQuery whose bottom padding matches the height of the bottom navigation bar will be added above the scaffold body. Children of the scaffold body that have been enclosed in a SafeArea or that are padded to match the MedaQuery's padding, can still avoid the bottom navigation bar.Sample App
Here's a complete example that demonstrates how the body's MediaQuery can be used.
There are 25 (0 - 24) textfield items in the list. Scrolling to the end completely exposes the last one because the list's bottom padding matches the MediaQuery:
When the keyboard appears the Scaffold's body is resized (the Scaffold's resizeToAvoidBottomInsets is true by default) and the body's MediaQuery no longer includes bottom padding.