Search code examples
flutterpaddingappbar

MediaQuery.of(context).padding is zero


When I try to increase the top padding by giving MediaQuery.of(context).padding.top doesn't work because all padding is zero.

I tried to wrap the parent widget with MediaQuery.removePadding but no luck. I don't have any AppBar upper in widget tree.

How can I solve this?


Solution

  • So the problem in my case was that I was launching a modal sheet from a tile widget where the padding of that context was zero. So what I did was to give the tile widget a callback, and instead of launching the modal sheet with the context of the tile widget, I launched it with the context of the main screen and everything was fine.