2 Commits
3 changed files with 36 additions and 15 deletions
+23 -2
View File
@@ -20,6 +20,7 @@ class LyricsPage extends StatefulWidget {
class _LyricsPageState extends State<LyricsPage> {
bool fetching = false;
String? lyrics;
bool instrumental = false;
@override
void initState() {
@@ -35,13 +36,16 @@ class _LyricsPageState extends State<LyricsPage> {
String path = widget.url.split('genius.com/')[1];
String fullLyrics = '';
if (await webScraper.loadWebPage('/$path?react=1')) {
webScraper.loadFromString(webScraper.getPageContent().replaceAll('<br>', '\n'));
var element = webScraper.getElement("div[data-lyrics-container]", ['data-lyrics-container']);
webScraper
.loadFromString(webScraper.getPageContent().replaceAll('<br>', '\n'));
var element = webScraper
.getElement("div[data-lyrics-container]", ['data-lyrics-container']);
for (var section in element) {
fullLyrics += section['title'] + '\n';
}
setState(() {
lyrics = fullLyrics;
instrumental = fullLyrics.isEmpty;
fetching = false;
});
}
@@ -82,6 +86,23 @@ class _LyricsPageState extends State<LyricsPage> {
),
],
)
: instrumental
? const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.music_note, size: 50),
SizedBox(width: 20, height: 20),
Text(
'This Song is an Instrumental',
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.italic,
),
),
],
),
)
: SizedBox(
width: MediaQuery.of(context).size.width,
child: SingleChildScrollView(
+1 -1
View File
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.3.4+3
version: 0.3.5+4
environment:
sdk: ">=3.0.0 <4.0.0"