Closed hewa-jalal closed 2 years ago
A similar problem. The floor panel is a MAPBOX card. The map considers its vertical size to be larger than the screen size of the device. You can see that the center of the map, marked in red, is shifted down.
In the second picture, the same map, in the same container, but without sliding_up_panel. The center is located correctly.
hey @adbelikov, for now, i just used the panel
as for the body widget and used collapsed
for the header and it works fine.
but i still don't know what is the purpose of body
property.
I have the same problem as mentioned by @adbelikov. As soon as I use the SlidingUpPanel widget in my scaffold (as outlined in the guide), the center of the body widget seems to be shifted downwards.
I checked with the source code and found out that the body widget (if specified) is put into a Container widget, whose height is derived from the screen height per MediaQuery. This is fine as long as there is (for example) no AppBar, whose height actually had to be taken into consideration during calculation of the container's height.
https://github.com/akshathjain/sliding_up_panel/blob/14705a7/lib/src/panel.dart#L265-269
In my case, when I remove the AppBar of my Scaffold (while Slide Panel in place), the center gets correctly aligned with the center of the screen. This is because the height available to the body equals to the full size of the screen as reported by the MediaQuery.
Same issue here, in addition to the AppBar, I have a BottomNavigationBar that makes things worse (the center is shifted down because of the AppBar AND the bottom of the map is hidden by the BottomNavigationBar)
In the meantime, as a workaround, I have removed the body and wrapped the SlidingUpPanel in a Stack with the former body below.
SlidingUpPanel(
header: MyHeader(),
panel: MyPanel(),
body: MyMap(),
),
Stack(
children: [
MyMap(),
SlidingUpPanel(
header: MyHeader(),
panel: MyPanel(),
),
],
),
My workaround is to keep the SlidingUpPanel and wrapping it with a MediaQuery.
So you go from this:
SlidingUpPanel(
child: MyMap(),
header: MyHeader(),
panel: MyPanel(),
...
)
To this:
LayoutBuilder(
builder: (_, constraints) {
final mediaQueryData = MediaQuery.of(context);
return MediaQuery(
data: mediaQueryData.copyWith(
size: constraints.biggest,
),
child: SlidingUpPanel(
/// Optionally you can then wrap the body with another [MediaQuery] and the
/// original [MediaQueryData] to prevent unexpected behaviour due to the now
/// incorrect [MediaQuery.size]
body: MediaQuery(
data: mediaQueryData,
child: MyMap(),
),
header: MyHeader(),
panel: MyPanel(),
...
)
)
}
)
@Shewebi work fine for me! thank you :)
@Shewebi you saved my day, thanks!
i am having a very weird problem with the panel and that's the body is being displayed outside, like this here is the code
where I use the panel:
and the body code:
BottomSheetTile