AssParser constructor
AssParser({
- required String content,
Implementation
AssParser({required String content}) {
_content = content;
var reg = RegExp(r'^\[(.*)\]', multiLine: true);
var rawSections = reg.allMatches(_content);
var sectionsMap = rawSections.toList().asMap();
sectionsMap.forEach((key, currentSection) {
dynamic nextSection;
int startIndex = currentSection.end;
var nextIndex = key + 1;
if (nextIndex <= sectionsMap.length - 1) {
nextSection = rawSections.elementAt(nextIndex);
}
var lines = _content.substring(startIndex, nextSection?.start);
var section = Section(
name: currentSection.group(0),
body: _parseSection(lines),
);
_sections.add(section);
for (var element in _sections.toList().elementAt(0).body) {
if (element.value['type'] != 'comment') {
_metadata.add(element);
}
}
});
}