Getting the screen size without the build context is simple in flutter apps.
Use WidgetsBinding to get the screen size without the build context. The complete Code is Given Below.
Mostly we use the Media query to get screen size in the flutter application But this short arrival Covers how to get screen size without context
Get Screen size without Build Context:
we can use the WidgetsBinding instance to get the height and the width of the screen
- Make Size Variable “screenSize”
- Add Value using WidgetBinding.instance.window.physiclSize’
- Now screenSize.width, screenSize.height will give you values
- Full Code Below
Size screenSize = WidgetsBinding.instance.window.physicalSize;
double width = screenSize.width;
double height = screenSize.height;
With Build Context:
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
This above code is responsible for getting high and width of the screen with the context.
This will solve your matter of getting Screen Size without the build context.
For more Flutter tutorials, Tips, Tricks, Free code, Questions, and Error Solving.
Remember FlutterDecode.com
Hi , I do believe this is an excellent blog. I stumbled upon it on Yahoo , i will come back once again. Money and freedom is the best way to change, may you be rich and help other people.
Thanks Buddy
Hello.This article was extremely interesting, particularly since I was browsing for thoughts on this matter last Thursday.
Hello there, I found your blog via Google while searching for a related topic, your website came up, it looks good. I’ve bookmarked it in my google bookmarks.
Thanks again for the blog.Really thank you!
This actually answered my problem, thank you!