visitLiteralMapExpression method

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

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);
      if (key is! LiteralSpreadExpression) {
        out.write(': ');
      }
      _acceptLiteral(value, out);
    });
    if (expression.values.length > 1) {
      out.write(', ');
    }
    return out..write('}');
  });
}