extractNumericValue function
Extract numeric value from an expression (handles literals and simple expressions)
Implementation
double? extractNumericValue(Expression expr) {
if (expr is DoubleLiteral) {
return expr.value;
}
if (expr is IntegerLiteral) {
return expr.value?.toDouble();
}
return null;
}