You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MediaQuery.of(context).padding can return EdgeInsets.zero #5483
When running on the Android emulator and occasionally when running Android native, MediaQuery.of(context).padding.top is zero the first time it's called at Widget initState() time. Calling it later, e.g. at build() time instead appears to consistently return the status bar's actual height.
This came up on the gallery demo's home screen, see #5368
In general MediaQuery.of() can return different values each time. That's why it's an InheritedWidget. Caching the value in initState is going to lead to bugs regardless.
The MediaQuery definitely didn't belong in initState().
On the other hand it seemed odd to report that the status bar's height was 0 and then ~25 later on, since the status bar is static. However I think the gist of this and #5259 is that developers need to deal with startup time zero-to-actual-value geometry changes.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
eseidelGoogle commentedon Aug 18, 2016
This sounds related to #5259 ?
Hixie commentedon Aug 18, 2016
In general MediaQuery.of() can return different values each time. That's why it's an InheritedWidget. Caching the value in initState is going to lead to bugs regardless.
HansMuller commentedon Aug 18, 2016
The MediaQuery definitely didn't belong in initState().
On the other hand it seemed odd to report that the status bar's height was 0 and then ~25 later on, since the status bar is static. However I think the gist of this and #5259 is that developers need to deal with startup time zero-to-actual-value geometry changes.
github-actions commentedon Sep 6, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.