simplified code across the app and consolidated duplicated helpers
This commit is contained in:
@@ -325,3 +325,12 @@ class PmUnknown extends PmNode {
|
||||
|
||||
const PmUnknown({required this.rawType, this.children = const []});
|
||||
}
|
||||
|
||||
final RegExp _cssLength = RegExp(r'^(\d+(?:\.\d+)?)(px|%|em|rem)$');
|
||||
|
||||
/// Splits a CSS length like `12px` / `1.5em` / `50%` into value and unit.
|
||||
({double value, String unit})? parsePmCssLength(String raw) {
|
||||
final match = _cssLength.firstMatch(raw);
|
||||
if (match == null) return null;
|
||||
return (value: double.parse(match.group(1)!), unit: match.group(2)!);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user