RenderErrorBox constructor Null safety

RenderErrorBox(
  1. [String message = '']
)

Creates a RenderErrorBox render object.

A message can optionally be provided. If a message is provided, an attempt will be made to render the message when the box paints.

Implementation

RenderErrorBox([ this.message = '' ]) {
  try {
    if (message != '') {
      // This class is intentionally doing things using the low-level
      // primitives to avoid depending on any subsystems that may have ended
      // up in an unstable state -- after all, this class is mainly used when
      // things have gone wrong.
      //
      // Generally, the much better way to draw text in a RenderObject is to
      // use the TextPainter class. If you're looking for code to crib from,
      // see the paragraph.dart file and the RenderParagraph class.
      final ui.ParagraphBuilder builder = ui.ParagraphBuilder(paragraphStyle);
      builder.pushStyle(textStyle);
      builder.addText(message);
      _paragraph = builder.build();
    } else {
      _paragraph = null;
    }
  } catch (error) {
    // If an error happens here we're in a terrible state, so we really should
    // just forget about it and let the developer deal with the already-reported
    // errors. It's unlikely that these errors are going to help with that.
  }
}