processText method
Process the text to get the parsed ChordLyricsDocument
Implementation
ChordLyricsDocument processText({
required String text,
required TextStyle lyricsStyle,
required TextStyle chordStyle,
double scaleFactor = 1.0,
int widgetPadding = 0,
int transposeIncrement = 0,
}) {
final List<String> lines = text.split('\n');
final MetadataHandler metadata = MetadataHandler();
_textScaleFactor = scaleFactor;
chordTransposer.transpose = transposeIncrement;
/// List to store our updated lines without overflows
final List<String> newLines = <String>[];
String currentLine = '';
///loop through the lines
for (int i = 0; i < lines.length; i++) {
currentLine = lines[i];
///If it finds some metadata skip to the next line
if (metadata.parseLine(currentLine)) {
continue;
}
//check if we have a long line
if (textWidth(currentLine, lyricsStyle) >= media) {
_handleLongLine(
currentLine: currentLine,
newLines: newLines,
lyricsStyle: lyricsStyle,
widgetPadding: widgetPadding);
} else {
//otherwise just add the regular line
newLines.add(currentLine.trim());
}
}
List<ChordLyricsLine> _chordLyricsLines = newLines
.map<ChordLyricsLine>(
(line) => _processLine(line, lyricsStyle, chordStyle))
.toList();
return ChordLyricsDocument(_chordLyricsLines,
capo: metadata.capo,
artist: metadata.artist,
title: metadata.title,
key: metadata.key);
}