writeInto method Null safety

  1. @override
void writeInto(
  1. GenerationContext context
)
override

Writes this component into the context by writing to its GenerationContext.buffer or by introducing bound variables. When writing into the buffer, no whitespace around the this component should be introduced. When a component consists of multiple composed component, it's responsible for introducing whitespace between its child components.

Implementation

@override
void writeInto(GenerationContext context) {
  // whether we need to insert a space before writing the next component
  var needsWhitespace = false;

  void writeWithSpace(Component? component) {
    if (component == null) return;

    if (needsWhitespace) context.writeWhitespace();
    component.writeInto(context);
    needsWhitespace = true;
  }

  writeStartPart(context);
  needsWhitespace = true;

  writeWithSpace(whereExpr);
  writeWithSpace(_groupBy);
  writeWithSpace(orderByExpr);
  writeWithSpace(limitExpr);
}