Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created December 28, 2025 19:13
Show Gist options
  • Select an option

  • Save fredgrott/f988440db23313b64f018a9f5c3bd964 to your computer and use it in GitHub Desktop.

Select an option

Save fredgrott/f988440db23313b64f018a9f5c3bd964 to your computer and use it in GitHub Desktop.
window width api calls
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