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

discontinuedreplaced by: dimension

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.

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
90
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.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_class_parser

More

Packages that depend on length_unit