song method

Future<Song?> song({
  1. required Genius client,
  2. required String songName,
})

Gets the artist's song return a Song in case of success and null otherwise.

If the song is in the artist's songs, returns the song. Otherwise searches Genius for the song and then returns the song.

Implementation

Future<Song?> song({required Genius client, required String songName}) async {
  for (var song in songs) {
    if (song.title != null) {
      if (song.title == songName) {
        return song;
      }
    }
  }

  return await client.searchSong(artist: name, title: songName);
}