Created
December 28, 2025 19:13
-
-
Save fredgrott/f988440db23313b64f018a9f5c3bd964 to your computer and use it in GitHub Desktop.
window width api calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final windowWidth = WindowWidth.of(context); | |
| return switch (wiindowWidth) { | |
| WindowWidth.compact => CompactLayout(), | |
| WindowWidth.medium => MediumLayout(), | |
| WindowWidth.expanded => ExpandedLayout(), | |
| _ => LargeLayout(), // large and extraLarge | |
| }; | |
| Widget build(BuildContext context) { | |
| final windowWidth = WindowWidth.of(context); | |
| // Use width to adapt your layout... | |
| } | |
| final windowWidth = WindowWidth.fromWidth(800); // Returns medium | |
| final windowWidth = WindowWidth.fromWidth(1400); // Returns large |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment