On this page
Dimension.css constructor
Dimension.css(Construct a Dimension object from the valid, simple CSS string cssValue
that represents a distance measurement.
This constructor is intended as a convenience method for working with simplistic CSS length measurements. Non-numeric values such as auto
or inherit
or invalid CSS will cause this constructor to throw a FormatError.
Source
Dimension.css(String cssValue) {
if (cssValue == '') cssValue = '0px';
if (cssValue.endsWith('%')) {
_unit = '%';
} else {
_unit = cssValue.substring(cssValue.length - 2);
}
if (cssValue.contains('.')) {
_value =
double.parse(cssValue.substring(0, cssValue.length - _unit.length));
} else {
_value = int.parse(cssValue.substring(0, cssValue.length - _unit.length));
}
}
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-html/Dimension/Dimension.css.html