paurakhsharma / flutter_chord

Lyrics Chord parser for Flutter
MIT License
24 stars 13 forks source link

How can I get the chord list? #5

Closed alexaung closed 2 years ago

alexaung commented 2 years ago

It is wonderful plugin. I am planing to use on my lyrics app. I am also planning to use this plugin, flutter_guitar_tabs together with your. If your plugin return all the chords sequentially then I don't need to write the another parser. Thanks.

paurakhsharma commented 2 years ago

Hey @alexaung you can to it already. Just use the package version 0.0.3

and use this code

ChordProcessor _chordProcessor = ChordProcessor(context);
ChordLyricsDocument chordLyricsDocument = _chordProcessor.processText(
  text: _lyrics,
  lyricsStyle: textStyle,
  chordStyle: chordStyle,
);

final chordList = <String>[];
chordLyricsDocument.chordLyricsLines.forEach((line) {
  line.chords.forEach((chord) {
    chordList.add(chord.chordText);
  });
});

print('chordList: $chordList');

final uniqueChordList = chordList.toSet().toList();

print('uniqueChordList: $uniqueChordList');

Hope it helps.

paurakhsharma commented 2 years ago

Hey @alexaung for now I am closing the issue. Feel free to re-open it, if your issue is not solved.

alexaung commented 2 years ago

@paurakhsharma Thanks you so much for support. It is really helpful. I will update you when I have done my project.