visitLiteralMapExpression method Null safety

  1. @override
StringSink visitLiteralMapExpression(
  1. LiteralMapExpression expression,
  2. [StringSink? output]
)
override

Implementation

@override
StringSink visitLiteralMapExpression(
  LiteralMapExpression expression, [
  StringSink? output,
]) {
  final out = output ??= StringBuffer();
  return _writeConstExpression(out, expression.isConst, () {
    if (expression.keyType != null) {
      out.write('<');
      expression.keyType!.accept(this, out);
      out.write(', ');
      if (expression.valueType == null) {
        const Reference('dynamic', 'dart:core').accept(this, out);
      } else {
        expression.valueType!.accept(this, out);
      }
      out.write('>');
    }
    out.write('{');
    visitAll<Object?>(expression.values.keys, out, (key) {
      final value = expression.values[key];
      _acceptLiteral(key, out);
      out.write(': ');
      _acceptLiteral(value, out);
    });
    return out..write('}');
  });
}