visitStringInterpolation method

  1. @override
Object? visitStringInterpolation(
  1. StringInterpolation node
)
override

Implementation

@override
Object? visitStringInterpolation(StringInterpolation node) {
  final buffer = StringBuffer();
  for (final element in node.elements) {
    if (element is InterpolationString) {
      buffer.write(element.value);
    } else if (element is InterpolationExpression) {
      final value = element.expression.accept<Object?>(this);
      // If the value is an async suspension, propagate it upward
      if (value is AsyncSuspensionRequest) {
        return value;
      }
      buffer.write(stringify(value)); // Use stringify helper
    } else {
      // Should not happen based on AST structure
      throw StateD4rtException(
          'Unknown interpolation element: ${element.runtimeType}');
    }
  }
  return buffer.toString();
}