visitLetVariableDeclaration method

  1. @override
List<Field>? visitLetVariableDeclaration(
  1. LetVariableDeclaration node
)
override

Implementation

@override
List<Field>? visitLetVariableDeclaration(LetVariableDeclaration node) {
  if (node.type is! UnitType) {
    final [expression] = node.body.accept(this) as List<Expression>;

    final field = Field((builder) {
      if (node.body.constant) {
        builder.modifier = FieldModifier.constant;
      } else {
        builder.modifier = FieldModifier.final$;
      }
      builder.name = node.name;
      builder.assignment = expression.code;
    });

    return [field];
  } else {
    return null;
  }
}