expressionToBorderWidth static method
double
expressionToBorderWidth(
- Expression? value
)
Implementation
static double expressionToBorderWidth(css.Expression? value) {
if (value is css.NumberTerm) {
return double.tryParse(value.text) ?? 1.0;
} else if (value is css.PercentageTerm) {
return (double.tryParse(value.text) ?? 400) / 100;
} else if (value is css.EmTerm) {
return double.tryParse(value.text) ?? 1.0;
} else if (value is css.RemTerm) {
return double.tryParse(value.text) ?? 1.0;
} else if (value is css.LengthTerm) {
return double.tryParse(value.text.replaceAll(RegExp(r'\s+(\d+\.\d+)\s+'), '')) ?? 1.0;
} else if (value is css.LiteralTerm) {
switch (value.text) {
case "thin":
return 2.0;
case "medium":
return 4.0;
case "thick":
return 6.0;
}
}
return 4.0;
}