length_unit 0.0.2 copy "length_unit: ^0.0.2" to clipboard
length_unit: ^0.0.2 copied to clipboard

discontinuedreplaced by: dimension
outdated

A Flutter package that introduce the Length class and some related class like DynamicOffset. It mimics the css length unit and supports four unit including px, percentage, vw and vh. The user would ne [...]

length_unit #

A Flutter package that introduce the Length class and some related class like DynamicOffset. It mimics the css length unit and supports four unit including px, percentage, vw and vh. The user would need to supply the constraint length and the screen size in order to get a px value from the Length class.

Having a length unit in Flutter can ease the process of creating responsive apps. Also, all the classes in this package can be serialized and deserialized.

Getting Started #

Create a Length instance:

var length=Length(10.0, unit: LengthUnit.percent)

Get the actual px value by calling:

double px=length.toPX(constraintSize: ???, screenSize: ???);

where the constraintSize you can get by using the LayoutBuilder and the screenSize you can get with MediaQuery.

You can also create Length instance from numbers. For example:

var length=10.toPXLength;

will create a Length instance with value 10 and unit px.

The DynamicOffset, DynamicRadius and DynamicBorderRadius classes are all using Length with the understanding that they will be provided with a Size and convert to the regular Flutter class Offset, Radius and BorderRadius classes.

var dynamicOffset=DynamicOffset(dx: 10.toPXLength, dy: 10.toPXLength);
Offset offset=dynamicOffset.toOffset(Size size);
1
likes
0
pub points
0%
popularity

Publisher

verified publisherwenkaifan.com

A Flutter package that introduce the Length class and some related class like DynamicOffset. It mimics the css length unit and supports four unit including px, percentage, vw and vh. The user would need to supply the constraint length and the screen size in order to get a px value from the Length class.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on length_unit