This is a library that helps with interfacing with the Spotify Api.
This package can help you interact with the following sections under the Spotify Api
- Artists
- Users
- Albums
- Genre
- Playlist
Get your api keys from Spotify.
The project requires a minimum SDK version on Android of 18.
Add this to your Manifest File on Android.
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="[INSERT_YOUR_CALLBACK_SCHEME]" />
</intent-filter>
</activity>
Ensure to authenticate first before using any of the methods. Do not forget to add your REDIRECT URI in your spotify dashboard and ensure they are the same as the one used to authenticate.
Hint: Your redirect Uri should be [YOUR_CALL_BACK_SCHEME]://[ANYTHING_YOU_WANT].com
_authenticate() async {
final response = await SpotifyApi.instance.authService.authorize(
redirectUri: '[INSERT_YOUR_REDERICT_URI]',
clientId: '[INSERT_YOUR_CLIENT_ID]',
callbackUrlScheme: '[INSERT_YOUR_CALL_BACK_SCHEME]',
//Optional: A space-separated list of scopes.To see a valid list of scopes check the spotify docs. Example below:
scope: 'user-read',
secretKey: '[INSERT_YOUR_SECRET_KEY]',
);
response.when(success: (success) {
//TODO: HANDLE SUCCESS
}, failure: (failure) {
//TODO: HANDLE FAILURE.
});
}
To get current users profile.
_getCurrentUserProfile() async {
final spotifyUserService = SpotifyApi.instance.userService;
final response = await spotifyUserService.getCurrentUsersProfile();
response.when(success: (success) {
print('Users name is ${success.displayName}');
}, failure: (failure) {
print('Failed ${failure.message}');
});
}
Please file issues, bugs, or feature requests in our issue tracker.
Feel free contribute a change to this plugin by opening a pull request.