From 89198e73c123f5fef27646e39bf648148aec9131 Mon Sep 17 00:00:00 2001 From: gmpassos Date: Tue, 20 Feb 2024 19:54:41 -0300 Subject: [PATCH 1/2] Fix lints for `lints: ^3.0.0` ; dart format --- .github/workflows/dart.yml | 26 ++++++++++++-------- analysis_options.yaml | 2 -- example/example.dart | 33 +++++++++++++++---------- example/example_auth.dart | 22 +++++++++++------ lib/src/authorization_scope.dart | 4 ++- lib/src/endpoints/albums.dart | 4 +-- lib/src/endpoints/artists.dart | 8 +++--- lib/src/endpoints/audio_analysis.dart | 4 +-- lib/src/endpoints/audio_features.dart | 4 +-- lib/src/endpoints/browse.dart | 4 +-- lib/src/endpoints/categories.dart | 4 +-- lib/src/endpoints/endpoint_base.dart | 2 +- lib/src/endpoints/endpoint_paging.dart | 27 +++++++++----------- lib/src/endpoints/episodes.dart | 6 ++--- lib/src/endpoints/markets.dart | 8 +++--- lib/src/endpoints/me.dart | 34 ++++++++++++-------------- lib/src/endpoints/player.dart | 14 +++++++---- lib/src/endpoints/playlists.dart | 4 +-- lib/src/endpoints/recommendations.dart | 8 +++--- lib/src/endpoints/search.dart | 4 +-- lib/src/endpoints/shows.dart | 6 ++--- lib/src/endpoints/tracks.dart | 4 +-- lib/src/endpoints/users.dart | 5 ++-- lib/src/models/album.dart | 2 +- lib/src/models/artist.dart | 2 +- lib/src/models/audio_analysis.dart | 2 +- lib/src/models/audio_feature.dart | 2 +- lib/src/models/category.dart | 2 +- lib/src/models/copyright.dart | 3 ++- lib/src/models/device.dart | 4 ++- lib/src/models/episode.dart | 3 +-- lib/src/models/error.dart | 2 +- lib/src/models/external_objects.dart | 2 +- lib/src/models/followers.dart | 2 +- lib/src/models/image.dart | 2 +- lib/src/models/market.dart | 4 ++- lib/src/models/paging.dart | 2 +- lib/src/models/player.dart | 5 +--- lib/src/models/playlist.dart | 2 +- lib/src/models/queue.dart | 2 +- lib/src/models/recommendations.dart | 2 +- lib/src/models/show.dart | 2 +- lib/src/models/track.dart | 2 +- lib/src/models/user.dart | 2 +- lib/src/spotify_api.dart | 14 +++++------ lib/src/spotify_base.dart | 2 +- lib/src/spotify_credentials.dart | 2 +- lib/src/spotify_exception.dart | 6 ++--- lib/src/utils.dart | 12 +++------ pubspec.yaml | 2 +- test/spotify_mock.dart | 17 ++++++++----- test/spotify_test.dart | 13 +++++----- 52 files changed, 188 insertions(+), 168 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index aef36ab..0c995a5 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -3,16 +3,22 @@ name: Dart CI on: [push, pull_request] jobs: - build: + build: runs-on: ubuntu-latest - - container: - image: dart:latest - steps: - - uses: actions/checkout@v1 - - name: Install dependencies - run: dart pub get - - name: Run tests - run: dart test + - uses: actions/checkout@v3 + - uses: dart-lang/setup-dart@v1 + - name: Dart version + run: | + dart --version + uname -a + - name: Install dependencies + run: dart pub get + - name: dart format + run: dart format -o none --set-exit-if-changed . + - name: dart analyze + run: dart analyze --fatal-infos --fatal-warnings . + - name: Run tests + run: dart run test + diff --git a/analysis_options.yaml b/analysis_options.yaml index c3331f7..a001094 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -10,8 +10,6 @@ linter: - cancel_subscriptions - close_sinks - hash_and_equals - - iterable_contains_unrelated_type - - list_remove_unrelated_type - test_types_in_equals - unrelated_type_equality_checks - valid_regexps diff --git a/example/example.dart b/example/example.dart index 108073d..3706a88 100644 --- a/example/example.dart +++ b/example/example.dart @@ -1,6 +1,8 @@ // Copyright (c) 2017, 2020 rinukkusu, hayribakici. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. +// ignore_for_file: deprecated_member_use_from_same_package + import 'dart:io'; import 'dart:convert'; import 'package:spotify/spotify.dart'; @@ -30,7 +32,9 @@ void main() async { print('\nArtists:'); var artists = await spotify.artists.list(['0OdUWJ0sBjDrqHygGUXeCF']); - artists.forEach((x) => print(x.name)); + for (var x in artists) { + print(x.name); + } print('\nAlbum:'); var album = await spotify.albums.get('2Hog1V8mdTWKhCYqI5paph'); @@ -38,35 +42,38 @@ void main() async { print('\nAlbum Tracks:'); var tracks = await spotify.albums.getTracks(album.id!).all(); - tracks.forEach((track) { + for (var track in tracks) { print(track.name); - }); + } print('\nNew Releases'); var newReleases = await spotify.browse.getNewReleases().first(); - newReleases.items!.forEach((album) => print(album.name)); + for (var album in newReleases.items!) { + print(album.name); + } print('\nFeatured Playlist:'); var featuredPlaylists = await spotify.playlists.featured.all(); - featuredPlaylists.forEach((playlist) { + for (var playlist in featuredPlaylists) { print(playlist.name); - }); + } print('\nUser\'s playlists:'); var usersPlaylists = await spotify.playlists.getUsersPlaylists('superinteressante').all(); - usersPlaylists.forEach((playlist) { + for (var playlist in usersPlaylists) { print(playlist.name); - }); + } - print("\nSearching for \'Metallica\':"); + print("\nSearching for 'Metallica':"); var search = await spotify.search.get('metallica').first(2); - search.forEach((pages) { + for (var pages in search) { if (pages.items == null) { print('Empty items'); } - pages.items!.forEach((item) { + + for (var item in pages.items!) { if (item is PlaylistSimple) { print('Playlist: \n' 'id: ${item.id}\n' @@ -123,8 +130,8 @@ void main() async { 'releaseDatePrecision: ${item.releaseDatePrecision}\n' '-------------------------------'); } - }); - }); + } + } var relatedArtists = await spotify.artists.relatedArtists('0OdUWJ0sBjDrqHygGUXeCF'); diff --git a/example/example_auth.dart b/example/example_auth.dart index 77c274c..1a2b48b 100644 --- a/example/example_auth.dart +++ b/example/example_auth.dart @@ -69,7 +69,8 @@ Future _getUserAuthenticatedSpotifyApi( print( 'Please paste this url \n\n$authUri\n\nto your browser and enter the redirected url:'); - var redirectUrl; + + Uri? redirectUrl; var userInput = stdin.readLineSync(); if (userInput == null || (redirectUrl = Uri.tryParse(userInput)) == null) { print('Invalid redirect url'); @@ -77,7 +78,7 @@ Future _getUserAuthenticatedSpotifyApi( } var client = - await grant.handleAuthorizationResponse(redirectUrl.queryParameters); + await grant.handleAuthorizationResponse(redirectUrl!.queryParameters); return SpotifyApi.fromClient(client); } @@ -309,16 +310,23 @@ Future> _getPlaylistTracks( Future _play(SpotifyApi spotify) async { var track = await spotify.tracks.get('6zW80jVqLtgSF1yCtGHiiD'); - print('Playing "${track.name} - ${track.artists?.first.name}" with track context for 10 s'); - var result = await spotify.player.startWithTracks(['spotify:track:6zW80jVqLtgSF1yCtGHiiD?si=99fd66ccb2464bad'], positionMs: 10000); + print( + 'Playing "${track.name} - ${track.artists?.first.name}" with track context for 10 s'); + var result = await spotify.player.startWithTracks( + ['spotify:track:6zW80jVqLtgSF1yCtGHiiD?si=99fd66ccb2464bad'], + positionMs: 10000); sleep(Duration(seconds: 10)); print('Pausing...'); spotify.player.pause(); var album = await spotify.albums.get('0rwbMKjNkp4ehQTwf9V2Jk'); track = await spotify.tracks.get('4VnDmjYCZkyeqeb0NIKqdA'); - print('Playing album "${album.name} - ${album.artists?.first.name}" with uri context'); - print('and offset to "${track.name} - ${track.artists?.first.name}" for 10 s'); - result = await spotify.player.startWithContext('spotify:album:0rwbMKjNkp4ehQTwf9V2Jk?si=HA-mX2mPQ1CUp7ExfdDt2g', offset: UriOffset('spotify:track:4VnDmjYCZkyeqeb0NIKqdA')); + print( + 'Playing album "${album.name} - ${album.artists?.first.name}" with uri context'); + print( + 'and offset to "${track.name} - ${track.artists?.first.name}" for 10 s'); + result = await spotify.player.startWithContext( + 'spotify:album:0rwbMKjNkp4ehQTwf9V2Jk?si=HA-mX2mPQ1CUp7ExfdDt2g', + offset: UriOffset('spotify:track:4VnDmjYCZkyeqeb0NIKqdA')); sleep(Duration(seconds: 10)); return result; diff --git a/lib/src/authorization_scope.dart b/lib/src/authorization_scope.dart index 6381325..b9c23c2 100644 --- a/lib/src/authorization_scope.dart +++ b/lib/src/authorization_scope.dart @@ -1,7 +1,9 @@ // Copyright (c) 2023, hayribakici. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +// ignore_for_file: deprecated_member_use_from_same_package + +part of '../spotify.dart'; /// Class holding all available authorization scopes. /// See [Spotify scopes documentation](https://developer.spotify.com/documentation/web-api/concepts/scopes) diff --git a/lib/src/endpoints/albums.dart b/lib/src/endpoints/albums.dart index 33fe9d4..e3b1c62 100644 --- a/lib/src/endpoints/albums.dart +++ b/lib/src/endpoints/albums.dart @@ -1,14 +1,14 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint for albums `v1/albums` class Albums extends EndpointPaging { @override String get _path => 'v1/albums'; - Albums(SpotifyApiBase api) : super(api); + Albums(super.api); /// Retrieves an album with its [albumId] Future get(String albumId) async { diff --git a/lib/src/endpoints/artists.dart b/lib/src/endpoints/artists.dart index 23f4bbc..efe148e 100644 --- a/lib/src/endpoints/artists.dart +++ b/lib/src/endpoints/artists.dart @@ -1,14 +1,14 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint for artists `v1/artists` class Artists extends EndpointPaging { @override String get _path => 'v1/artists'; - Artists(SpotifyApiBase api) : super(api); + Artists(super.api); /// Retrieves an artist with its [artistId] Future get(String artistId) async { @@ -72,9 +72,9 @@ class Artists extends EndpointPaging { Market? country, List? includeGroups, }) { - final _includeGroups = includeGroups?.join(','); + final includeGroups0 = includeGroups?.join(','); final query = _buildQuery({ - 'include_groups': _includeGroups, + 'include_groups': includeGroups0, 'country': country?.name, }); return _getPages( diff --git a/lib/src/endpoints/audio_analysis.dart b/lib/src/endpoints/audio_analysis.dart index 607554a..1b61f4d 100644 --- a/lib/src/endpoints/audio_analysis.dart +++ b/lib/src/endpoints/audio_analysis.dart @@ -1,14 +1,14 @@ // Copyright (c) 2021, grabajuice. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint of a tracks audio analysis class AudioAnalysisEndpoint extends EndpointBase { @override String get _path => 'v1/audio-analysis'; - AudioAnalysisEndpoint(SpotifyApiBase api) : super(api); + AudioAnalysisEndpoint(super.api); Future get(String trackId) async { var jsonString = await _api._get('$_path/$trackId'); diff --git a/lib/src/endpoints/audio_features.dart b/lib/src/endpoints/audio_features.dart index ba8a4d2..feeac2d 100644 --- a/lib/src/endpoints/audio_features.dart +++ b/lib/src/endpoints/audio_features.dart @@ -1,14 +1,14 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint of audio features `v1/audio-features` class AudioFeatures extends EndpointBase { @override String get _path => 'v1/audio-features'; - AudioFeatures(SpotifyApiBase api) : super(api); + AudioFeatures(super.api); /// Returns audio features of a track with [trackId] Future get(String trackId) async { diff --git a/lib/src/endpoints/browse.dart b/lib/src/endpoints/browse.dart index f0d13a3..c0dd5d9 100644 --- a/lib/src/endpoints/browse.dart +++ b/lib/src/endpoints/browse.dart @@ -1,8 +1,8 @@ -part of spotify; +part of '../../spotify.dart'; /// Endpoint of browse `v1/browse` class Browse extends EndpointPaging { - Browse(SpotifyApiBase api) : super(api); + Browse(super.api); @override String get _path => 'v1/browse'; diff --git a/lib/src/endpoints/categories.dart b/lib/src/endpoints/categories.dart index 89aefd8..71a82e7 100644 --- a/lib/src/endpoints/categories.dart +++ b/lib/src/endpoints/categories.dart @@ -1,11 +1,11 @@ -part of spotify; +part of '../../spotify.dart'; /// Endpoint of browsing the categories `v1/browse/categories` class Categories extends Browse { @override String get _path => '${super._path}/categories'; - Categories(SpotifyApiBase api) : super(api); + Categories(super.api); /// [country] - a country: an ISO 3166-1 alpha-2 country code. Provide this /// parameter if you want to narrow the list of returned categories to those diff --git a/lib/src/endpoints/endpoint_base.dart b/lib/src/endpoints/endpoint_base.dart index b03bf20..e90329b 100644 --- a/lib/src/endpoints/endpoint_base.dart +++ b/lib/src/endpoints/endpoint_base.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Base class of all endpoint classes abstract class EndpointBase { diff --git a/lib/src/endpoints/endpoint_paging.dart b/lib/src/endpoints/endpoint_paging.dart index de94eb3..ecd0fee 100644 --- a/lib/src/endpoints/endpoint_paging.dart +++ b/lib/src/endpoints/endpoint_paging.dart @@ -1,11 +1,11 @@ // Copyright (c) 2017, 2018, hayribakici, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Base class of all endpoints using pagination abstract class EndpointPaging extends EndpointBase { - EndpointPaging(SpotifyApiBase api) : super(api); + EndpointPaging(super.api); Pages _getPages(String path, ParserFunction pageItemParser, [String? pageKey, ParserFunction? pageContainerParser]) => @@ -63,9 +63,7 @@ abstract class BasePage { /// A page that uses an offset to get to the next page. class Page extends BasePage { - Page(Paging _paging, ParserFunction pageItemParser, - [Object? pageContainer]) - : super(_paging, pageItemParser, pageContainer); + Page(Paging super._paging, super.pageItemParser, [super.pageContainer]); @override bool get isLast { @@ -85,9 +83,8 @@ class Page extends BasePage { /// A page that uses a cursor to get to the next page class CursorPage extends BasePage { - CursorPage(CursorPaging _paging, ParserFunction pageItemParser, - [Object? pageContainer]) - : super(_paging, pageItemParser, pageContainer); + CursorPage(CursorPaging super._paging, super.pageItemParser, + [super.pageContainer]); @override dynamic get _next => (_paging as CursorPaging).cursors?.after ?? ''; @@ -202,7 +199,7 @@ abstract class SinglePages> extends _Pages firstPage.then(handlePageAndGetNext); }, onCancel: () { _cancelled = true; - return Future.value(true); + return; }, onResume: () { _bufferedPages.forEach(stream.add); if (_bufferedPages.last.isLast) { @@ -216,9 +213,8 @@ abstract class SinglePages> extends _Pages /// Handles retrieval of a page through an offset class Pages extends SinglePages> with OffsetStrategy> { - Pages(SpotifyApiBase api, String path, ParserFunction pageParser, - [String? pageKey, ParserFunction? pageContainerMapper]) - : super(api, path, pageParser, pageKey, pageContainerMapper); + Pages(super.api, super.path, super.pageParser, + [super.pageKey, super.pageContainerMapper]); Pages.fromPaging( SpotifyApiBase api, Paging paging, ParserFunction pageParser, @@ -250,9 +246,8 @@ class Pages extends SinglePages> with OffsetStrategy> { /// Handles retrieval of a page through a cursor class CursorPages extends SinglePages> with CursorStrategy> { - CursorPages(SpotifyApiBase api, String path, ParserFunction pageParser, - [String? pageKey, ParserFunction? pageContainerMapper]) - : super(api, path, pageParser, pageKey, pageContainerMapper); + CursorPages(super.api, super.path, super.pageParser, + [super.pageKey, super.pageContainerMapper]); CursorPages.fromCursorPaging( SpotifyApiBase api, CursorPaging paging, ParserFunction pageParser, @@ -306,7 +301,7 @@ class BundledPages extends _Pages with OffsetStrategy>> { _pageMappers.forEach((key, value) { if (map[key] != null) { var paging = Paging.fromJson(map[key]); - var page; + Page page; if (_pageContainerParser == null) { page = Page(paging, value); } else { diff --git a/lib/src/endpoints/episodes.dart b/lib/src/endpoints/episodes.dart index 5012cc9..09702c0 100644 --- a/lib/src/endpoints/episodes.dart +++ b/lib/src/endpoints/episodes.dart @@ -1,19 +1,19 @@ // Copyright (c) 2023, hayribakici. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint of episodes `v1/episodes` class Episodes extends EndpointBase { @override String get _path => 'v1/episodes'; - Episodes(SpotifyApiBase api) : super(api); + Episodes(super.api); Future get(String id, [Market? market]) async { assert(id.isNotEmpty, 'No episode id was provided'); var jsonString = - await _api._get('$_path/$id?' + _buildQuery({'market': market?.name})); + await _api._get('$_path/$id?${_buildQuery({'market': market?.name})}'); return EpisodeFull.fromJson(jsonDecode(jsonString)); } diff --git a/lib/src/endpoints/markets.dart b/lib/src/endpoints/markets.dart index d2cfc6a..3351a81 100644 --- a/lib/src/endpoints/markets.dart +++ b/lib/src/endpoints/markets.dart @@ -1,15 +1,15 @@ -part of spotify; +part of '../../spotify.dart'; /// Endpoint for `v1/markets` class Markets extends EndpointBase { @override String get _path => 'v1/markets'; - Markets(SpotifyApiBase api) : super(api); + Markets(super.api); /// Get the list of markets where Spotify is available. - /// A result of `null` means that the country is not mapped - /// in this library. + /// A result of `null` means that the country is not mapped + /// in this library. Future> get availableMarkets async { var jsonString = await _api._get(_path); var map = json.decode(jsonString); diff --git a/lib/src/endpoints/me.dart b/lib/src/endpoints/me.dart index 3a39143..23ab82a 100644 --- a/lib/src/endpoints/me.dart +++ b/lib/src/endpoints/me.dart @@ -1,20 +1,20 @@ // Copyright (c) 2019, chances, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; abstract class _MeEndpointBase extends EndpointPaging { @override String get _path => 'v1/me'; - _MeEndpointBase(SpotifyApiBase api) : super(api); + _MeEndpointBase(super.api); } /// Endpoint for authenticated users `v1/me/*` class Me extends _MeEndpointBase { late PlayerEndpoint _player; - Me(SpotifyApiBase api, PlayerEndpoint player) : super(api) { + Me(super.api, PlayerEndpoint player) { _player = player; } @@ -57,11 +57,11 @@ class Me extends _MeEndpointBase { FollowingType type, List ids) async { assert(ids.isNotEmpty, 'No user/artist id was provided'); - final jsonString = await _api._get('$_path/following/contains?' + - _buildQuery({ + final jsonString = + await _api._get('$_path/following/contains?${_buildQuery({ 'type': type._key, 'ids': ids.join(','), - })); + })}'); final list = List.castFrom(json.decode(jsonString)); return Map.fromIterables(ids, list); } @@ -103,12 +103,11 @@ class Me extends _MeEndpointBase { 'Cannot specify both after and before.'); return _getCursorPages( - '$_path/player/recently-played?' + - _buildQuery({ + '$_path/player/recently-played?${_buildQuery({ 'limit': limit, 'after': after?.millisecondsSinceEpoch, 'before': before?.millisecondsSinceEpoch - }), + })}', (json) => PlayHistory.fromJson(json)); } @@ -139,10 +138,9 @@ class Me extends _MeEndpointBase { Pages _top( _TopItemsType type, T Function(dynamic) parser, TimeRange range) => _getPages( - '$_path/top/${type.name}?' + - _buildQuery({ + '$_path/top/${type.name}?${_buildQuery({ 'time_range': range._key, - }), + })}', parser); /// Get information about a user’s available devices. @@ -159,7 +157,7 @@ class Me extends _MeEndpointBase { /// [ids] - the ids of the shows to save Future saveShows(List ids) async { assert(ids.isNotEmpty, 'No show ids were provided for saving'); - await _api._put('$_path/shows?' + _buildQuery({'ids': ids.join(',')})); + await _api._put('$_path/shows?${_buildQuery({'ids': ids.join(',')})}'); } /// Removes shows for the current user. It requires the `user-library-modify` @@ -173,7 +171,7 @@ class Me extends _MeEndpointBase { 'ids': ids.join(','), 'market': market?.name, }; - await _api._delete('$_path/shows?' + _buildQuery(queryMap)); + await _api._delete('$_path/shows?${_buildQuery(queryMap)}'); } /// Check if passed albums (ids) are saved by current user. @@ -183,7 +181,7 @@ class Me extends _MeEndpointBase { assert( ids.isNotEmpty, 'No show ids were provided for checking saved shows'); var query = _buildQuery({'ids': ids.join(',')}); - var jsonString = await _api._get('$_path/shows/contains?' + query); + var jsonString = await _api._get('$_path/shows/contains?$query'); var response = List.castFrom(jsonDecode(jsonString)); return Map.fromIterables(ids, response); @@ -239,7 +237,7 @@ class Me extends _MeEndpointBase { /// [ids] - the ids of the episodes Future saveEpisodes(List ids) async { assert(ids.isNotEmpty, 'No episode ids were provided for saving'); - await _api._put('$_path/episodes?' + _buildQuery({'ids': ids.join(',')})); + await _api._put('$_path/episodes?${_buildQuery({'ids': ids.join(',')})}'); } /// Removes episodes for the current user. Requires the `user-library-modify` @@ -248,7 +246,7 @@ class Me extends _MeEndpointBase { Future removeEpisodes(List ids) async { assert(ids.isNotEmpty, 'No episode ids were provided for removing'); await _api - ._delete('$_path/episodes?' + _buildQuery({'ids': ids.join(',')})); + ._delete('$_path/episodes?${_buildQuery({'ids': ids.join(',')})}'); } /// Check if passed episode [ids] are saved by current user. @@ -256,7 +254,7 @@ class Me extends _MeEndpointBase { Future> containsSavedEpisodes(List ids) async { assert(ids.isNotEmpty, 'No episode ids were provided for checking'); final jsonString = await _api._get( - '$_path/episodes/contains?' + _buildQuery({'ids': ids.join(',')})); + '$_path/episodes/contains?${_buildQuery({'ids': ids.join(',')})}'); final result = List.castFrom(json.decode(jsonString)); return Map.fromIterables(ids, result); diff --git a/lib/src/endpoints/player.dart b/lib/src/endpoints/player.dart index f5761ca..d290cd4 100644 --- a/lib/src/endpoints/player.dart +++ b/lib/src/endpoints/player.dart @@ -1,14 +1,16 @@ // Copyright (c) 2022, 2023, chances, rinukkusu, hayribakici. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +// ignore_for_file: deprecated_member_use_from_same_package + +part of '../../spotify.dart'; /// Endpoint of the player class PlayerEndpoint extends _MeEndpointBase { @override String get _path => '${super._path}/player'; - PlayerEndpoint(SpotifyApiBase api) : super(api); + PlayerEndpoint(super.api); /// Toggle Shuffle For User's Playback. /// @@ -38,7 +40,8 @@ class PlayerEndpoint extends _MeEndpointBase { /// and active device. Returns an empty [PlaybackState] object when /// no playback context has been started. Future playbackState([Market? market]) async { - var jsonString = await _api._get('$_path?${_buildQuery({'market': market?.name})}'); + var jsonString = + await _api._get('$_path?${_buildQuery({'market': market?.name})}'); if (jsonString.isEmpty) { return PlaybackState(); @@ -141,14 +144,15 @@ class PlayerEndpoint extends _MeEndpointBase { /// /// Note: Before starting a new playback context check the [playbackState] /// if necessary before [resume]ing, otherwise you overwrite the current - /// context. + /// context. Future startWithContext(String contextUri, {String? deviceId, Offset? offset, bool retrievePlaybackState = true}) async { assert( contextUri.isNotEmpty, 'Cannot start playback with empty context uri'); - var options = StartWithContextOptions(contextUri: contextUri, offset: offset); + var options = + StartWithContextOptions(contextUri: contextUri, offset: offset); return startOrResume( deviceId: deviceId, options: options, diff --git a/lib/src/endpoints/playlists.dart b/lib/src/endpoints/playlists.dart index e91a91b..f5a2d11 100644 --- a/lib/src/endpoints/playlists.dart +++ b/lib/src/endpoints/playlists.dart @@ -1,14 +1,14 @@ // Copyright (c) 2017, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint of playlists class Playlists extends EndpointPaging { @override String get _path => 'v1/browse'; - Playlists(SpotifyApiBase api) : super(api); + Playlists(super.api); Future get(String playlistId) async { return Playlist.fromJson( diff --git a/lib/src/endpoints/recommendations.dart b/lib/src/endpoints/recommendations.dart index 20d8e16..748d01b 100644 --- a/lib/src/endpoints/recommendations.dart +++ b/lib/src/endpoints/recommendations.dart @@ -1,10 +1,10 @@ -part of spotify; +part of '../../spotify.dart'; class RecommendationsEndpoint extends EndpointBase { @override String get _path => 'v1/recommendations'; - RecommendationsEndpoint(SpotifyApiBase api) : super(api); + RecommendationsEndpoint(super.api); /// Generates a list of size [limit] of tracks based on /// [seedArtists], [seedGenres], [seedTracks] spotify IDs @@ -34,7 +34,9 @@ class RecommendationsEndpoint extends EndpointBase { 'seed_tracks': seedTracks }.forEach((key, list) => _addList(parameters, key, list!)); if (market != null) parameters['market'] = market.name; - [min, max, target].forEach((map) => _addTunableTrackMap(parameters, map)); + for (var map in [min, max, target]) { + _addTunableTrackMap(parameters, map); + } final pathQuery = Uri(path: _path, queryParameters: parameters) .toString() .replaceAll(RegExp(r'%2C'), ','); diff --git a/lib/src/endpoints/search.dart b/lib/src/endpoints/search.dart index ac87518..9bd70ee 100644 --- a/lib/src/endpoints/search.dart +++ b/lib/src/endpoints/search.dart @@ -1,14 +1,14 @@ // Copyright (c) 2018 hayribakici, ebarnsli. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint of the search `v1/search` class Search extends EndpointPaging { @override String get _path => 'v1/search'; - Search(SpotifyApiBase api) : super(api); + Search(super.api); /// Get Spotify Catalog information about albums, artists, playlists, /// tracks, shows or episodes that match a keyword string. diff --git a/lib/src/endpoints/shows.dart b/lib/src/endpoints/shows.dart index 3199725..4d04c71 100644 --- a/lib/src/endpoints/shows.dart +++ b/lib/src/endpoints/shows.dart @@ -1,14 +1,14 @@ // Copyright (c) 2020, deandreamatias, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint of shows `v1/shows` class Shows extends EndpointPaging { @override String get _path => 'v1/shows'; - Shows(SpotifyApiBase api) : super(api); + Shows(super.api); /// Get a single show /// @@ -16,7 +16,7 @@ class Shows extends EndpointPaging { /// If a country code is specified, only artists, albums, and tracks with /// content that is playable in that market is returned. Future get(String showId, {Market? market}) async { - var jsonString; + String jsonString; if (market != null) { var queryMap = {'market': market.name}; var query = _buildQuery(queryMap); diff --git a/lib/src/endpoints/tracks.dart b/lib/src/endpoints/tracks.dart index 5f08311..7aea125 100644 --- a/lib/src/endpoints/tracks.dart +++ b/lib/src/endpoints/tracks.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; /// Endpoint of tracks `v1/tracks` class Tracks extends EndpointBase { @@ -47,7 +47,7 @@ class TracksMe extends EndpointPaging { @override String get _path => 'v1/me/tracks'; - TracksMe(SpotifyApiBase api) : super(api); + TracksMe(super.api); Pages get saved { return _getPages(_path, (json) => TrackSaved.fromJson(json)); diff --git a/lib/src/endpoints/users.dart b/lib/src/endpoints/users.dart index 9834e5d..89545a4 100644 --- a/lib/src/endpoints/users.dart +++ b/lib/src/endpoints/users.dart @@ -1,14 +1,13 @@ // Copyright (c) 2017, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../../spotify.dart'; class Users extends EndpointPaging { - @override String get _path => 'v1/users'; - Users(SpotifyApiBase api) : super(api); + Users(super.api); Future get(String userId) async { var jsonString = await _api._get('$_path/$userId'); diff --git a/lib/src/models/album.dart b/lib/src/models/album.dart index b61c7db..c679c79 100644 --- a/lib/src/models/album.dart +++ b/lib/src/models/album.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of an album @JsonSerializable(createToJson: false) diff --git a/lib/src/models/artist.dart b/lib/src/models/artist.dart index 50f8d43..26faa07 100644 --- a/lib/src/models/artist.dart +++ b/lib/src/models/artist.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of an artist @JsonSerializable(createToJson: false) diff --git a/lib/src/models/audio_analysis.dart b/lib/src/models/audio_analysis.dart index 66505a0..15cb783 100644 --- a/lib/src/models/audio_analysis.dart +++ b/lib/src/models/audio_analysis.dart @@ -1,7 +1,7 @@ // Copyright (c) 2021, grabajuice. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// JSON representation of a track's analysis information @JsonSerializable(createToJson: false) diff --git a/lib/src/models/audio_feature.dart b/lib/src/models/audio_feature.dart index 07fea95..a3b6a33 100644 --- a/lib/src/models/audio_feature.dart +++ b/lib/src/models/audio_feature.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of an audio feature @JsonSerializable(createToJson: false) diff --git a/lib/src/models/category.dart b/lib/src/models/category.dart index 736cb89..304d9b3 100644 --- a/lib/src/models/category.dart +++ b/lib/src/models/category.dart @@ -1,4 +1,4 @@ -part of spotify.models; +part of '_models.dart'; /// Json representation of a category @JsonSerializable(createToJson: false) diff --git a/lib/src/models/copyright.dart b/lib/src/models/copyright.dart index 82acd79..76d0add 100644 --- a/lib/src/models/copyright.dart +++ b/lib/src/models/copyright.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of copyright @JsonSerializable(createToJson: false) @@ -21,6 +21,7 @@ class Copyright extends Object { enum CopyrightType { /// C = the copyright C, + /// P = the sound recording (performance) copyright. P } diff --git a/lib/src/models/device.dart b/lib/src/models/device.dart index ab561cb..3790ba0 100644 --- a/lib/src/models/device.dart +++ b/lib/src/models/device.dart @@ -1,7 +1,9 @@ // Copyright (c) 2020, hayribakici. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +// ignore_for_file: constant_identifier_names + +part of '_models.dart'; /// Json representation of a device @JsonSerializable(createToJson: false) diff --git a/lib/src/models/episode.dart b/lib/src/models/episode.dart index 3f85d5b..7067179 100644 --- a/lib/src/models/episode.dart +++ b/lib/src/models/episode.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of an episode @JsonSerializable(createToJson: false) @@ -80,7 +80,6 @@ class Episode extends Object { /// Json representation of an episode with information about its show @JsonSerializable(createToJson: false) class EpisodeFull extends Episode { - EpisodeFull(); Show? show; diff --git a/lib/src/models/error.dart b/lib/src/models/error.dart index 9a02e6e..2e9e6d2 100644 --- a/lib/src/models/error.dart +++ b/lib/src/models/error.dart @@ -1,7 +1,7 @@ // Copyright (c) 2018, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of an API error @JsonSerializable(createToJson: false) diff --git a/lib/src/models/external_objects.dart b/lib/src/models/external_objects.dart index f2c23f8..d810703 100644 --- a/lib/src/models/external_objects.dart +++ b/lib/src/models/external_objects.dart @@ -1,7 +1,7 @@ // Copyright (c) 2019, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of an external url @JsonSerializable(createToJson: false) diff --git a/lib/src/models/followers.dart b/lib/src/models/followers.dart index 2565f88..4921d83 100644 --- a/lib/src/models/followers.dart +++ b/lib/src/models/followers.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of followers @JsonSerializable(createToJson: false) diff --git a/lib/src/models/image.dart b/lib/src/models/image.dart index 63ab5f8..eb9352f 100644 --- a/lib/src/models/image.dart +++ b/lib/src/models/image.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of an image @JsonSerializable(createToJson: false) diff --git a/lib/src/models/market.dart b/lib/src/models/market.dart index 7b21068..aebc6f8 100644 --- a/lib/src/models/market.dart +++ b/lib/src/models/market.dart @@ -1,5 +1,7 @@ // Copyright (c) 2019-2021, Denis Portnov. All rights reserved. -part of spotify.models; +part of '_models.dart'; + +// ignore_for_file: constant_identifier_names enum Market { AD, diff --git a/lib/src/models/paging.dart b/lib/src/models/paging.dart index c3cda9e..0274ec7 100644 --- a/lib/src/models/paging.dart +++ b/lib/src/models/paging.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; typedef ParserFunction = T Function(dynamic object); diff --git a/lib/src/models/player.dart b/lib/src/models/player.dart index 335f963..5138353 100644 --- a/lib/src/models/player.dart +++ b/lib/src/models/player.dart @@ -1,7 +1,7 @@ // Copyright (c) 2018, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of the playback state @JsonSerializable(createToJson: false) @@ -123,7 +123,6 @@ abstract class StartOrResumeOptions extends Object { @JsonSerializable(createFactory: false) class StartWithContextOptions extends StartOrResumeOptions { - StartWithContextOptions({this.contextUri, this.offset}); /// Optional. Spotify URI of the context to play. Valid contexts are albums, @@ -146,7 +145,6 @@ class StartWithContextOptions extends StartOrResumeOptions { @JsonSerializable(createFactory: false) class StartWithUrisOptions extends StartOrResumeOptions { - StartWithUrisOptions({this.uris, this.positionMs}); /// Optional. A JSON array of the Spotify track URIs to play. @@ -166,7 +164,6 @@ class StartWithUrisOptions extends StartOrResumeOptions { @override Map toJson() => _$StartWithUrisOptionsToJson(this); - } abstract class Offset { diff --git a/lib/src/models/playlist.dart b/lib/src/models/playlist.dart index c751132..1aed2ff 100644 --- a/lib/src/models/playlist.dart +++ b/lib/src/models/playlist.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of a playlist @JsonSerializable(createToJson: false) diff --git a/lib/src/models/queue.dart b/lib/src/models/queue.dart index b365858..206b0fd 100644 --- a/lib/src/models/queue.dart +++ b/lib/src/models/queue.dart @@ -1,4 +1,4 @@ -part of spotify.models; +part of '_models.dart'; /// Json representation of the playback queue @JsonSerializable(createToJson: false) diff --git a/lib/src/models/recommendations.dart b/lib/src/models/recommendations.dart index 044d52b..4a4c7ff 100644 --- a/lib/src/models/recommendations.dart +++ b/lib/src/models/recommendations.dart @@ -1,4 +1,4 @@ -part of spotify.models; +part of '_models.dart'; /// Json representation of the recommendations @JsonSerializable(createToJson: false) diff --git a/lib/src/models/show.dart b/lib/src/models/show.dart index 329d335..5fefae6 100644 --- a/lib/src/models/show.dart +++ b/lib/src/models/show.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of a show @JsonSerializable(createToJson: false) diff --git a/lib/src/models/track.dart b/lib/src/models/track.dart index 2a02b4e..30c802e 100644 --- a/lib/src/models/track.dart +++ b/lib/src/models/track.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of a track @JsonSerializable(createToJson: false) diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 91a5cb9..95c0623 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify.models; +part of '_models.dart'; /// Json representation of a user @JsonSerializable(createToJson: false) diff --git a/lib/src/spotify_api.dart b/lib/src/spotify_api.dart index 085ff13..9ae7e6d 100644 --- a/lib/src/spotify_api.dart +++ b/lib/src/spotify_api.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, 'rinukkusu'. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../spotify.dart'; /// Accesspoint for the spotify api /// @@ -17,15 +17,13 @@ class SpotifyApi extends SpotifyApiBase { {Function(SpotifyApiCredentials)? onCredentialsRefreshed}) : super(credentials, http.Client(), onCredentialsRefreshed); - SpotifyApi.fromClient(FutureOr client) - : super.fromClient(client); + SpotifyApi.fromClient(FutureOr super.client) + : super.fromClient(); - SpotifyApi.fromAuthCodeGrant( - oauth2.AuthorizationCodeGrant grant, String responseUri) - : super.fromAuthCodeGrant(grant, responseUri); + SpotifyApi.fromAuthCodeGrant(super.grant, super.responseUri) + : super.fromAuthCodeGrant(); - SpotifyApi.withAccessToken(String accessToken) - : super._withAccessToken(accessToken); + SpotifyApi.withAccessToken(super.accessToken) : super._withAccessToken(); static Future asyncFromCredentials( SpotifyApiCredentials credentials, { diff --git a/lib/src/spotify_base.dart b/lib/src/spotify_base.dart index 2170329..4506295 100644 --- a/lib/src/spotify_base.dart +++ b/lib/src/spotify_base.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, 'rinukkusu'. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../spotify.dart'; abstract class SpotifyApiBase { static const String _baseUrl = 'https://api.spotify.com'; diff --git a/lib/src/spotify_credentials.dart b/lib/src/spotify_credentials.dart index b61d4fb..149a7e3 100644 --- a/lib/src/spotify_credentials.dart +++ b/lib/src/spotify_credentials.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../spotify.dart'; /// Holds information about credentials to access the api. class SpotifyApiCredentials { diff --git a/lib/src/spotify_exception.dart b/lib/src/spotify_exception.dart index 8a02161..63b2c78 100644 --- a/lib/src/spotify_exception.dart +++ b/lib/src/spotify_exception.dart @@ -1,7 +1,7 @@ // Copyright (c) 2018, chances. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../spotify.dart'; class SpotifyException implements Exception { int? status; @@ -22,6 +22,6 @@ class SpotifyException implements Exception { class ApiRateException extends SpotifyException { final num retryAfter; - ApiRateException.fromSpotify(SpotifyError error, this.retryAfter) - : super.fromSpotify(error); + ApiRateException.fromSpotify(super.error, this.retryAfter) + : super.fromSpotify(); } diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 544f27a..8ba94b6 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -1,7 +1,7 @@ // Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. -part of spotify; +part of '../spotify.dart'; Iterable> batches(Iterable source, int size) sync* { List? accumulator; @@ -18,12 +18,8 @@ Iterable> batches(Iterable source, int size) sync* { /// Helper function to overcome the current /// [spotify bug](https://community.spotify.com/t5/Spotify-for-Developers/The-response-type-of-artist-endpoint-is-marked-as-Integer-in/m-p/5800044#M12164) int? convertToIntIfDoubleValue(dynamic jsonValue) { - switch (jsonValue.runtimeType) { - case double: - return (jsonValue as double).toInt(); - case int: - return jsonValue as int; - default: - return null; + if (jsonValue is num) { + return jsonValue.toInt(); } + return null; } diff --git a/pubspec.yaml b/pubspec.yaml index ce06cd6..72d1da4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: oauth2: ^2.0.2 dev_dependencies: - lints: ">=2.1.1 <4.0.0" + lints: ^3.0.0 test: ^1.24.6 build_runner: ^2.4.6 json_serializable: ">=6.7.1 <7.0.0" diff --git a/test/spotify_mock.dart b/test/spotify_mock.dart index 4a5eb9c..7577782 100644 --- a/test/spotify_mock.dart +++ b/test/spotify_mock.dart @@ -12,8 +12,11 @@ class SpotifyApiMock extends SpotifyApiBase { set mockHttpErrors(Iterator errors) => (client as MockClient)._mockHttpErrors = errors; - - set interceptor(Function(String method, String url, Map? headers, [String? body])? interceptor) => + + set interceptor( + Function(String method, String url, Map? headers, + [String? body])? + interceptor) => (client as MockClient).interceptFunction = interceptor; } @@ -25,9 +28,11 @@ class MockClient implements oauth2.Client { _mockHttpErrors = mockHttpErrors; } - Function(String method, String url, Map? headers, [String? body])? interceptFunction; + Function(String method, String url, Map? headers, + [String? body])? interceptFunction; - void _intercept(String method, String url, Map? headers, [String? body]) { + void _intercept(String method, String url, Map? headers, + [String? body]) { if (interceptFunction != null) { interceptFunction!(method, url, headers, body); } @@ -108,7 +113,7 @@ class MockClient implements oauth2.Client { @override Future put(url, {Map? headers, body, Encoding? encoding}) async { - _intercept('PUT', url.toString(), headers, body.toString()); + _intercept('PUT', url.toString(), headers, body.toString()); return createSuccessResponse(_readPath(url)); } @@ -158,7 +163,7 @@ class MockClient implements oauth2.Client { } String _wrapMessageToJson(int statusCode, String message) => - '{ \"error\": {\"status\":$statusCode,\"message\": \"$message\"}}'; + '{ "error": {"status":$statusCode,"message": "$message"}}'; } class MockHttpError { diff --git a/test/spotify_test.dart b/test/spotify_test.dart index fa0073d..d019dde 100644 --- a/test/spotify_test.dart +++ b/test/spotify_test.dart @@ -1,9 +1,10 @@ import 'dart:async'; -import 'dart:convert'; import 'spotify_mock.dart'; import 'package:test/test.dart'; import 'package:spotify/spotify.dart'; +// ignore_for_file: deprecated_member_use_from_same_package + Future main() async { var spotify = SpotifyApiMock(SpotifyApiCredentials( 'clientId', @@ -284,7 +285,7 @@ Future main() async { expect(result.first.type, DeviceType.Computer); expect(result.first.volumePercent, 100); - // the second entry does not have a valid [DeviceType], + // the second entry does not have a valid [DeviceType], // and should have `Unknown` instead. expect(result.last.type, DeviceType.Unknown); }); @@ -486,7 +487,6 @@ Future main() async { expect(result.actions?.pausing, true); }); - test('startWithContext', () async { spotify.interceptor = (method, url, headers, [body]) { // checking sincce startWithContext makes a PUT and a GET request @@ -494,10 +494,12 @@ Future main() async { if (method == 'PUT') { expect(method, 'PUT'); expect(body, isNotNull); - expect(body, '{"context_uri":"contextUri","offset":{"uri":"urioffset"}}'); + expect(body, + '{"context_uri":"contextUri","offset":{"uri":"urioffset"}}'); } }; - await spotify.player.startWithContext('contextUri', offset: UriOffset('urioffset')); + await spotify.player + .startWithContext('contextUri', offset: UriOffset('urioffset')); }); test('startWithUris', () async { @@ -512,7 +514,6 @@ Future main() async { }; await spotify.player.startWithTracks(['track1'], positionMs: 10); }); - }); group('Tracks', () { From 94003eae8aaeea870d619fca2fbfb97b0f1e0883 Mon Sep 17 00:00:00 2001 From: gmpassos Date: Wed, 28 Feb 2024 14:37:43 -0300 Subject: [PATCH 2/2] dart format --- lib/src/spotify_base.dart | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/src/spotify_base.dart b/lib/src/spotify_base.dart index 5bfd7ee..2f8a26c 100644 --- a/lib/src/spotify_base.dart +++ b/lib/src/spotify_base.dart @@ -10,55 +10,55 @@ abstract class SpotifyApiBase { 'https://accounts.spotify.com/authorize'; bool _shouldWait = false; - - late FutureOr _client; + + late FutureOr _client; FutureOr get client => _client; - + late Artists _artists; Artists get artists => _artists; - + late Albums _albums; Albums get albums => _albums; - + late Browse _browse; Browse get browse => _browse; - + late Tracks _tracks; Tracks get tracks => _tracks; - + late Playlists _playlists; Playlists get playlists => _playlists; - + late Episodes _episodes; Episodes get episodes => _episodes; - + late RecommendationsEndpoint _recommendations; RecommendationsEndpoint get recommendations => _recommendations; - + late Markets _markets; Markets get markets => _markets; - + late Users _users; Users get users => _users; - + late Search _search; Search get search => _search; - + late AudioFeatures _audioFeatures; AudioFeatures get audioFeatures => _audioFeatures; - + late AudioAnalysisEndpoint _audioAnalysis; AudioAnalysisEndpoint get audioAnalysis => _audioAnalysis; - + late Categories _categories; Categories get categories => _categories; - + late Me _me; Me get me => _me; - + late PlayerEndpoint _player; PlayerEndpoint get player => _player; - + late Shows _shows; Shows get shows => _shows;