Heading constructor

Heading({
  1. Text? text,
  2. List<Text>? texts,
  3. int type = 1,
})

Main heading constructor.

Can receive a single text or a list of texts. If both are included also both fields are added to the heading content adding first the text field.

Also can receive the type of the heading as an integer between 1 and 3. Set to 1 by default when no specified or when is out of the range declared before.

Implementation

Heading({
  Text? text,
  List<Text>? texts,
  int type: 1,
}) {
  if (text != null) {
    _content.add(text);
  }
  if (texts != null) {
    _content.addAll(texts);
  }

  switch (type) {
    case 3:
      this.type = BlockTypes.H3;
      break;
    case 2:
      this.type = BlockTypes.H2;
      break;
    case 1:
    default:
      this.type = BlockTypes.H1;
  }
}