Skip to content

Commit

Permalink
Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Oct 18, 2023
1 parent 47021d8 commit 6d18161
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 106 deletions.
8 changes: 4 additions & 4 deletions lib/API/musify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ Future<List<dynamic>> getUserPlaylists() async {

String addUserPlaylist(String playlistId, BuildContext context) {
if (playlistId.length != 34) {
return '${context.l10n()!.notYTlist}!';
return '${context.l10n!.notYTlist}!';
} else {
userPlaylists.add(playlistId);
addOrUpdateData('user', 'playlists', userPlaylists);
return '${context.l10n()!.addedSuccess}!';
return '${context.l10n!.addedSuccess}!';
}
}

Expand All @@ -123,7 +123,7 @@ String createCustomPlaylist(
};
userCustomPlaylists.add(customPlaylist);
addOrUpdateData('user', 'customPlaylists', userCustomPlaylists);
return '${context.l10n()!.addedSuccess}!';
return '${context.l10n!.addedSuccess}!';
}

String addSongInCustomPlaylist(
Expand Down Expand Up @@ -387,7 +387,7 @@ Future updatePlaylistList(

playlists[index]['list'] = songList;
addOrUpdateData('cache', 'playlistSongs$playlistId', songList);
showToast(context, context.l10n()!.playlistUpdated);
showToast(context, context.l10n!.playlistUpdated);
}
return playlists[index];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/l10n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

extension ContextX on BuildContext {
AppLocalizations? l10n() => AppLocalizations.of(this);
AppLocalizations? get l10n => AppLocalizations.of(this);
}
2 changes: 1 addition & 1 deletion lib/screens/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AboutPage extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(
context.l10n()!.about,
context.l10n!.about,
),
),
body: const SingleChildScrollView(child: AboutCards()),
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/artist_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _ArtistPagePageState extends State<ArtistPage> {
if (snapshot.hasError || snapshot.data.isEmpty) {
return Center(
child: Text(
'${context.l10n()!.nothingFound}!',
'${context.l10n!.nothingFound}!',
style: TextStyle(
color: colorScheme.primary,
fontSize: 18,
Expand Down Expand Up @@ -107,7 +107,7 @@ class _ArtistPagePageState extends State<ArtistPage> {
setActivePlaylist(widget.playlist);
showToast(
context,
context.l10n()!.queueInitText,
context.l10n!.queueInitText,
);
},
child: Icon(
Expand Down
8 changes: 4 additions & 4 deletions lib/screens/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _HomePageState extends State<HomePage> {
width: context.screenSize.width / 1.4,
child: MarqueeWidget(
child: Text(
context.l10n()!.suggestedPlaylists,
context.l10n!.suggestedPlaylists,
style: TextStyle(
color: colorScheme.primary,
fontSize: 20,
Expand Down Expand Up @@ -165,7 +165,7 @@ class _HomePageState extends State<HomePage> {
Widget _buildErrorWidget(BuildContext context) {
return Center(
child: Text(
'${context.l10n()!.error}!',
'${context.l10n!.error}!',
style: TextStyle(
color: colorScheme.primary,
fontSize: 18,
Expand All @@ -190,7 +190,7 @@ class _HomePageState extends State<HomePage> {
width: context.screenSize.width / 1.4,
child: MarqueeWidget(
child: Text(
context.l10n()!.suggestedArtists,
context.l10n!.suggestedArtists,
style: TextStyle(
color: colorScheme.primary,
fontSize: 20,
Expand Down Expand Up @@ -232,7 +232,7 @@ class _HomePageState extends State<HomePage> {
Padding(
padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
child: Text(
context.l10n()!.recommendedForYou,
context.l10n!.recommendedForYou,
style: TextStyle(
color: colorScheme.primary,
fontSize: 20,
Expand Down
Loading

0 comments on commit 6d18161

Please sign in to comment.