tryParse static method
Implementation
static XPathDouble? tryParse(String text, [XPathType type = xsDouble]) {
final trimmed = text.trim();
if (trimmed == 'INF' || trimmed == '+INF') {
return type == xsDouble ? infinity : XPathDouble(double.infinity, type);
}
if (trimmed == '-INF') {
return type == xsDouble
? negativeInfinity
: XPathDouble(double.negativeInfinity, type);
}
if (trimmed == 'NaN') {
return type == xsDouble ? nan : XPathDouble(double.nan, type);
}
final val = double.tryParse(trimmed);
if (val == null) return null;
return XPathDouble(type == xsFloat ? roundToFloat(val) : val, type);
}