combineRecreateTextLine static method

TextLine combineRecreateTextLine(
  1. TextElement startElement,
  2. List<TextBlock> blocks
)

Return a BrsTextLine : It's full line by combining left and right all TextElement on the same line of "startElement", including "startElement". Ex :

List<BrsTextBlock> blocks =  [['How', 'are', 'you', '?']['Welcome', '!']];
BrsTextElement startElement = 'are';
Result : BrsTextElement = ['How','are','you','?','Welcome', '!']

Implementation

static TextLine combineRecreateTextLine(
    TextElement startElement, List<TextBlock> blocks) {
  List<TextElement> listTextElement = [startElement];

  bool asNext = true;
  while (asNext) {
    TextElement? nextElement =
        nextTextElement(listTextElement, blocks, HorizontalDirection.left);
    nextElement == null ? asNext = false : listTextElement.add(nextElement);
  }

  listTextElement = listTextElement.reversed.toList();
  asNext = true;

  while (asNext) {
    TextElement? nextElement =
        nextTextElement(listTextElement, blocks, HorizontalDirection.right);
    nextElement == null ? asNext = false : listTextElement.add(nextElement);
  }

  return TextLine(
    elements: listTextElement,
  );
}