build method Null safety

  1. @override
void build(
  1. ParagraphBuilder builder,
  2. {double textScaleFactor = 1.0,
  3. List<PlaceholderDimensions>? dimensions}
)
override

Adds a placeholder box to the paragraph builder if a size has been calculated for the widget.

Sizes are provided through dimensions, which should contain a 1:1 in-order mapping of widget to laid-out dimensions. If no such dimension is provided, the widget will be skipped.

The textScaleFactor will be applied to the laid-out size of the widget.

Implementation

@override
void build(ui.ParagraphBuilder builder, { double textScaleFactor = 1.0, List<PlaceholderDimensions>? dimensions }) {
  assert(debugAssertIsValid());
  assert(dimensions != null);
  final bool hasStyle = style != null;
  if (hasStyle) {
    builder.pushStyle(style!.getTextStyle(textScaleFactor: textScaleFactor));
  }
  assert(builder.placeholderCount < dimensions!.length);
  final PlaceholderDimensions currentDimensions = dimensions![builder.placeholderCount];
  builder.addPlaceholder(
    currentDimensions.size.width,
    currentDimensions.size.height,
    alignment,
    scale: textScaleFactor,
    baseline: currentDimensions.baseline,
    baselineOffset: currentDimensions.baselineOffset,
  );
  if (hasStyle) {
    builder.pop();
  }
}