| OLD | NEW |
| 1 part of html; | 1 part of html; |
| 2 | 2 |
| 3 /** | 3 /** |
| 4 * Class representing a | 4 * Class representing a |
| 5 * [length measurement](https://developer.mozilla.org/en-US/docs/Web/CSS/length) | 5 * [length measurement](https://developer.mozilla.org/en-US/docs/Web/CSS/length) |
| 6 * in CSS. | 6 * in CSS. |
| 7 */ | 7 */ |
| 8 @Experimental() | 8 @Experimental() |
| 9 class Dimension { | 9 class Dimension { |
| 10 num _value; | 10 num _value; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 * FormatError. | 59 * FormatError. |
| 60 */ | 60 */ |
| 61 Dimension.css(String cssValue) { | 61 Dimension.css(String cssValue) { |
| 62 if (cssValue == '') cssValue = '0px'; | 62 if (cssValue == '') cssValue = '0px'; |
| 63 if (cssValue.endsWith('%')) { | 63 if (cssValue.endsWith('%')) { |
| 64 _unit = '%'; | 64 _unit = '%'; |
| 65 } else { | 65 } else { |
| 66 _unit = cssValue.substring(cssValue.length - 2); | 66 _unit = cssValue.substring(cssValue.length - 2); |
| 67 } | 67 } |
| 68 if (cssValue.contains('.')) { | 68 if (cssValue.contains('.')) { |
| 69 _value = double.parse(cssValue.substring(0, | 69 _value = |
| 70 cssValue.length - _unit.length)); | 70 double.parse(cssValue.substring(0, cssValue.length - _unit.length)); |
| 71 } else { | 71 } else { |
| 72 _value = int.parse(cssValue.substring(0, cssValue.length - _unit.length)); | 72 _value = int.parse(cssValue.substring(0, cssValue.length - _unit.length)); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 /** Print out the CSS String representation of this value. */ | 76 /** Print out the CSS String representation of this value. */ |
| 77 String toString() { | 77 String toString() { |
| 78 return '${_value}${_unit}'; | 78 return '${_value}${_unit}'; |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** Return a unitless, numerical value of this CSS value. */ | 81 /** Return a unitless, numerical value of this CSS value. */ |
| 82 num get value => this._value; | 82 num get value => this._value; |
| 83 } | 83 } |
| OLD | NEW |