SizerExt extension
It helps to be able to use the sizes by means of screen percentages in an easy way
and using only the MediaQuery through the BuildContext but without having to create
an instance of MediaQuery or having to use it directly by writing it completely.
For example you can use 20.h(context) and you are automatically pointing to MediaQuery.of(context).size.height * 20
- on
Methods
-
h(
BuildContext context) → double - Calculates the height depending on the device's screen size Eg: 20.h(context) -> will take 20% of the screen's height
-
parentH(
BoxConstraints constraints) → double - Calculates the height depending on the parent's height, Eg: 20.parentH -> will take 20% of the parent's height. You must use a LayoutBuilder to get the constraints of the parent and use the his height.
-
parentSP(
BoxConstraints constraints) → double -
Available on num, provided by the SizerExt extension
Calculates the sp (Scalable Pixel) depending on the parent's size Eg: 12.parentSP(constraints) Makes the specified size look the same on all screen sizes. Which means it's going to look just as big in terms of design. If you want it to always be the same size in pixels just usesize: 12as it is done by default. -
parentW(
BoxConstraints constraints) → double - Calculates the height depending on the parent's width, Eg: 20.parentW(constraints) -> will take 20% of the parent's width. You must use a LayoutBuilder to get the constraints of the parent and use the his width.
-
sp(
BuildContext context) → double -
Available on num, provided by the SizerExt extension
Calculates the sp (Scalable Pixel) depending on the device's screen size Eg: 12.sp(context) Makes the specified size look the same on all screen sizes. Which means it's going to look just as big in terms of design. If you want it to always be the same size in pixels just usefont-size: 12as it is done by default. -
w(
BuildContext context) → double - Calculates the width depending on the device's screen size Eg: 20.w(context) -> will take 20% of the screen's width