visitTernaryExpr method

  1. @override
void visitTernaryExpr(
  1. TernaryExpr node
)
override

e1 ? e2 : e3

Implementation

@override
void visitTernaryExpr(TernaryExpr node) {
  node.subAccept(this);
  if (node.condition.isConstValue && node.value is bool) {
    bool condition = node.condition.value;
    if (condition) {
      node.value = node.thenBranch.value;
    } else {
      node.value = node.elseBranch.value;
    }
  }
}