visitIf method

  1. @override
void visitIf(
  1. IfStmt node
)
override

Implementation

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