gitmyhub

flutter-sized-context

Dart ★ 115 updated 3y ago

Flutter code extension that provides MediaQuery sizing info directly on the BuildContext instance. Also adds some helper methods for sizing and layout.

A Flutter helper package that provides simple, clean shortcuts for getting screen dimensions, orientation, and percentage-based sizing without repetitive boilerplate code.

FlutterDartsetup: easycomplexity 2/5

Flutter-sized-context is a helper package for Flutter apps that makes it quicker and cleaner to work with screen sizes and layouts. If you've ever built a Flutter app and gotten tired of writing the same long, repetitive line of code every time you need to know how wide the screen is, this package solves that problem. It lets you grab screen dimensions and orientation details directly, cutting down on boilerplate code so you can focus on designing your app's interface.

Normally in Flutter, to find out the screen's width or whether the phone is held vertically or horizontally, you have to call a specific built-in tool and dig through its properties. This package simplifies that by attaching those details directly to the context—the core building block Flutter uses to understand where a widget is in the app's tree. Instead of writing a clunky query, you can just ask for the width in pixels or check if the device is in landscape mode using a short, simple command.

Who would use this? Any Flutter developer building an app that needs to look good on different screen sizes. For example, if you are designing an app and want a two-column layout on tablets but a single column on small phones, this makes it easy to check the physical device size in inches to make that switch. It also provides handy shortcuts for percentage-based sizing. If you want an element to take up exactly 10 percent of the screen's width, you can ask for that directly rather than calculating the math yourself.

The project is straightforward and focuses on doing one thing well: saving developers time and making their layout code easier to read. By reducing the friction of accessing screen measurements, it helps keep your codebase tidy, especially as your app grows and you find yourself checking screen dimensions in dozens of places.

Where it fits