visitField method Null safety

  1. @override
StringSink visitField(
  1. Field spec,
  2. [StringSink? output]
)

Implementation

@override
StringSink visitField(Field spec, [StringSink? output]) {
  output ??= StringBuffer();
  spec.docs.forEach(output.writeln);
  spec.annotations.forEach((a) => visitAnnotation(a, output));
  if (spec.static) {
    output.write('static ');
  }
  if (spec.late) {
    output.write('late ');
  }
  switch (spec.modifier) {
    case FieldModifier.var$:
      if (spec.type == null) {
        output.write('var ');
      }
      break;
    case FieldModifier.final$:
      output.write('final ');
      break;
    case FieldModifier.constant:
      output.write('const ');
      break;
  }
  if (spec.type != null) {
    spec.type!.type.accept(this, output);
    output.write(' ');
  }
  output.write(spec.name);
  if (spec.assignment != null) {
    output.write(' = ');
    startConstCode(spec.modifier == FieldModifier.constant, () {
      spec.assignment!.accept(this, output);
    });
  }
  output.writeln(';');
  return output;
}