Chord constructor
Chord(
- String chordString
Implementation
Chord(String chordString) {
String propertiesRegex =
ChordProperty.chordPropertyList.map((e) => e._getRegex()).join();
RegExp chordExpression = RegExp(
'^(?<note>[A-H])(?<accidental>#|b|##|bb)?(?<minor>m?)(?<extension>$propertiesRegex)(?<base_part>\\/(?<base_note>[A-H])(?<base_accidental>#|b|##|bb)?)?\$');
RegExpMatch? match = chordExpression.firstMatch(chordString);
assert(match != null);
note = Note.fromString(
match!.namedGroup('note')! + match.namedGroup('accidental')!);
chordType =
match.namedGroup('minor') == 'm' ? ChordType.minor : ChordType.major;
// print(match.gr);
properties = ChordProperty.chordPropertyList
.where((element) => (match.namedGroup(element.identifier) ?? '') != '')
.toList();
}