Skip to content
Snippets Groups Projects
Commit bec180f9 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Use flutter linter, apply lints, update dependencies

parent fadd6108
No related branches found
No related tags found
1 merge request!56Resolve "Use flutter linter and apply lints"
Pipeline #5050 passed
Showing
with 105 additions and 90 deletions
include: package:flutter_lints/flutter.yaml
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.52
app.versionCode=52
app.versionName=0.0.53
app.versionCode=53
Add automatic flutter linter. Apply code lints. Update dependencies.
Ajout d'un correcteur automatique de code. Application des corrections. Mise à jour des dépendances.
......@@ -21,13 +21,14 @@ class Artist {
Map<String, Object?>? toJson() {
return {
'id': this.id,
'name': this.name,
'mbid': this.mbid,
'id': id,
'name': name,
'mbid': mbid,
};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -22,15 +22,16 @@ class CountsByDayData {
Map<String, Object?>? toJson() {
Map<String, double> map = {};
this.data.keys.forEach((day) {
double? value = this.data[day];
for (var day in data.keys) {
double? value = data[day];
map[day.toString()] = value != null ? value.toDouble() : 0.0;
});
}
return {'counts-by-day': map};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -24,15 +24,16 @@ class CountsByHourData {
Map<String, Object?>? toJson() {
Map<String, double> map = {};
this.data.keys.forEach((day) {
double? value = this.data[day];
for (var day in data.keys) {
double? value = data[day];
map[day.toString()] = value != null ? value.toDouble() : 0.0;
});
}
return {'counts-by-hour': map};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -39,18 +39,19 @@ class DiscoveriesData {
Map<String, Object?>? toJson() {
Map<String, Map<String, int>> map = {};
this.data.keys.forEach((element) {
DiscoveriesDataValue? item = this.data[element];
for (var element in data.keys) {
DiscoveriesDataValue? item = data[element];
map[element] = {
'new-artists': item != null ? item.newArtistsCount : 0,
'new-tracks': item != null ? item.newTracksCount : 0,
};
});
}
return map;
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -15,9 +15,9 @@ class HeatmapData {
Map<String, dynamic> rawDataForThisDay = json['heatmap'][day];
Map<int, int> dataForThisDay = {};
rawDataForThisDay.keys.forEach((hour) {
for (var hour in rawDataForThisDay.keys) {
dataForThisDay[int.parse(hour)] = int.parse(rawDataForThisDay[hour].toString());
});
}
data[int.parse(day)] = dataForThisDay;
});
......@@ -29,18 +29,19 @@ class HeatmapData {
Map<String, dynamic> toJson() {
Map<String, Map<String, int>> map = {};
this.data.keys.forEach((day) {
for (var day in data.keys) {
Map<String, int> dayMap = {};
this.data[day]?.forEach((hour, count) {
data[day]?.forEach((hour, count) {
dayMap[hour.toString()] = count;
});
map[day.toString()] = dayMap;
});
}
return {'heatmap': map};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -43,19 +43,20 @@ class NewArtistsData {
List<Map<String, dynamic>> toJson() {
List<Map<String, dynamic>> list = [];
this.data.forEach((item) {
for (var item in data) {
list.add({
'firstPlayed': {
'date': item.firstPlayed != null ? item.firstPlayed.toString() : null,
'date': item.firstPlayed?.toString(),
},
'artist': item.artist?.toJson(),
});
});
}
return list;
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -43,19 +43,20 @@ class NewTracksData {
List<Map<String, dynamic>> toJson() {
List<Map<String, dynamic>> list = [];
this.data.forEach((item) {
for (var item in data) {
list.add({
'firstPlayed': {
'date': item.firstPlayed != null ? item.firstPlayed.toString() : null,
'date': item.firstPlayed?.toString(),
},
'track': item.track?.toJson(),
});
});
}
return list;
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -22,14 +22,15 @@ class StatisticsGlobalData {
Map<String, Object?>? toJson() {
return <String, Object?>{
'totalCount': this.totalCount,
'totalCount': totalCount,
'lastScrobble': {
'date': this.lastScrobble != null ? this.lastScrobble.toString() : null,
'date': lastScrobble?.toString(),
},
};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -29,14 +29,15 @@ class StatisticsRecentData {
Map<String, Object?>? toJson() {
return <String, Object?>{
'recentCount': this.recentCount,
'firstPlayedArtistsCount': this.firstPlayedArtistsCount,
'firstPlayedTracksCount': this.firstPlayedTracksCount,
'selectedPeriod': this.selectedPeriod,
'recentCount': recentCount,
'firstPlayedArtistsCount': firstPlayedArtistsCount,
'firstPlayedTracksCount': firstPlayedTracksCount,
'selectedPeriod': selectedPeriod,
};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -39,18 +39,19 @@ class TimelineData {
Map<String, Object?>? toJson() {
Map<String, Map<String, int>> map = {};
this.data.keys.forEach((element) {
TimelineDataValue? item = this.data[element];
for (var element in data.keys) {
TimelineDataValue? item = data[element];
map[element] = {
'counts': item != null ? item.counts : 0,
'eclecticism': item != null ? item.eclecticism : 0,
};
});
}
return map;
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -38,7 +38,7 @@ class TopArtistsStreamDataValue {
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -98,15 +98,15 @@ class TopArtistsData {
List<Map<String, Object>> listArtists = [];
Map<String, List<Map<String, double>>> artistsStreamMap = {};
this.topArtists.forEach((TopArtistsDataValue? item) {
for (TopArtistsDataValue item in topArtists) {
listArtists.add({
'artistName': item != null ? item.artistName : '',
'count': item != null ? item.count : 0,
});
'artistName': item.artistName,
'count': item.count,
});
}
this.topArtistsStream.keys.forEach((dateAsString) {
List<TopArtistsStreamDataValue>? items = this.topArtistsStream[dateAsString];
for (var dateAsString in topArtistsStream.keys) {
List<TopArtistsStreamDataValue>? items = topArtistsStream[dateAsString];
List<Map<String, double>> values = [];
items?.forEach((item) {
values.add({
......@@ -114,7 +114,7 @@ class TopArtistsData {
});
});
artistsStreamMap[dateAsString] = values;
});
}
return {
'top-artists': listArtists,
......@@ -122,7 +122,8 @@ class TopArtistsData {
};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -26,14 +26,15 @@ class Track {
Map<String, Object?>? toJson() {
return {
'id': this.id,
'name': this.name,
'mbid': this.mbid,
'artist': this.artist.toJson(),
'id': id,
'name': name,
'mbid': mbid,
'artist': artist.toJson(),
};
}
@override
String toString() {
return jsonEncode(this.toJson());
return jsonEncode(toJson());
}
}
......@@ -16,7 +16,7 @@ class ScrobblesApi {
static String baseUrl = 'https://scrobble.harrault.fr';
static Future<StatisticsGlobalData> fetchGlobalStatistics() async {
final String url = baseUrl + '/stats';
final String url = '$baseUrl/stats';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -27,7 +27,7 @@ class ScrobblesApi {
}
static Future<StatisticsRecentData> fetchRecentStatistics(int daysCount) async {
final String url = baseUrl + '/' + daysCount.toString() + '/stats';
final String url = '$baseUrl/$daysCount/stats';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -38,7 +38,7 @@ class ScrobblesApi {
}
static Future<TimelineData> fetchTimeline(int daysCount) async {
final String url = baseUrl + '/data/' + daysCount.toString() + '/timeline';
final String url = '$baseUrl/data/$daysCount/timeline';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -49,7 +49,7 @@ class ScrobblesApi {
}
static Future<CountsByDayData> fetchCountsByDay(int daysCount) async {
final String url = baseUrl + '/data/' + daysCount.toString() + '/counts-by-day';
final String url = '$baseUrl/data/$daysCount/counts-by-day';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -60,7 +60,7 @@ class ScrobblesApi {
}
static Future<CountsByHourData> fetchCountsByHour(int daysCount) async {
final String url = baseUrl + '/data/' + daysCount.toString() + '/counts-by-hour';
final String url = '$baseUrl/data/$daysCount/counts-by-hour';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -71,7 +71,7 @@ class ScrobblesApi {
}
static Future<DiscoveriesData> fetchDiscoveries(int daysCount) async {
final String url = baseUrl + '/data/' + daysCount.toString() + '/news';
final String url = '$baseUrl/data/$daysCount/news';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -82,7 +82,7 @@ class ScrobblesApi {
}
static Future<TopArtistsData> fetchTopArtists(int daysCount) async {
final String url = baseUrl + '/data/' + daysCount.toString() + '/top-artists';
final String url = '$baseUrl/data/$daysCount/top-artists';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -93,7 +93,7 @@ class ScrobblesApi {
}
static Future<HeatmapData> fetchHeatmap(int daysCount) async {
final String url = baseUrl + '/data/' + daysCount.toString() + '/heatmap';
final String url = '$baseUrl/data/$daysCount/heatmap';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -104,7 +104,7 @@ class ScrobblesApi {
}
static Future<NewArtistsData> fetchNewArtists(int count) async {
final String url = baseUrl + '/data/discoveries/artists/' + count.toString();
final String url = '$baseUrl/data/discoveries/artists/$count';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......@@ -115,7 +115,7 @@ class ScrobblesApi {
}
static Future<NewTracksData> fetchNewTracks(int count) async {
final String url = baseUrl + '/data/discoveries/tracks/' + count.toString();
final String url = '$baseUrl/data/discoveries/tracks/$count';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
......
......@@ -15,19 +15,19 @@ class ScreenDiscoveries extends StatelessWidget {
color: Theme.of(context).colorScheme.background,
child: RefreshIndicator(
onRefresh: () async {
this.notifyParent();
notifyParent();
},
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 4),
physics: const BouncingScrollPhysics(),
children: <Widget>[
const SizedBox(height: 8),
const CardDiscoveries(),
const SizedBox(height: 6),
const CardNewArtists(),
const SizedBox(height: 6),
const CardNewTracks(),
const SizedBox(height: 36),
children: const <Widget>[
SizedBox(height: 8),
CardDiscoveries(),
SizedBox(height: 6),
CardNewArtists(),
SizedBox(height: 6),
CardNewTracks(),
SizedBox(height: 36),
],
),
),
......
......@@ -16,21 +16,21 @@ class ScreenHome extends StatelessWidget {
color: Theme.of(context).colorScheme.background,
child: RefreshIndicator(
onRefresh: () async {
this.notifyParent();
notifyParent();
},
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 4),
physics: const BouncingScrollPhysics(),
children: <Widget>[
const SizedBox(height: 8),
const CardStatisticsGlobal(),
const SizedBox(height: 6),
const CardStatisticsRecent(),
const SizedBox(height: 6),
const CardTimeline(),
const SizedBox(height: 6),
const CardTopArtists(),
const SizedBox(height: 36),
children: const <Widget>[
SizedBox(height: 8),
CardStatisticsGlobal(),
SizedBox(height: 6),
CardStatisticsRecent(),
SizedBox(height: 6),
CardTimeline(),
SizedBox(height: 6),
CardTopArtists(),
SizedBox(height: 36),
],
),
),
......
......@@ -15,9 +15,9 @@ class ScreenSettings extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 4),
physics: const BouncingScrollPhysics(),
children: <Widget>[
SizedBox(height: 8),
const SizedBox(height: 8),
AppTitle1(text: tr('settings_title')),
SettingsForm(),
const SettingsForm(),
],
),
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment