getLibraryState static method

Future<LibraryState?> getLibraryState({
  1. required String spotifyUri,
})

Gets the LibraryState of the given spotifyUri

Throws a PlatformException when getting the library state failed Throws a MissingPluginException if the method is not implemented on the native platforms.

Implementation

static Future<LibraryState?> getLibraryState(
    {required String spotifyUri}) async {
  try {
    var libraryStateJson = await (_channel.invokeMethod<String>(
        MethodNames.getLibraryState, {ParamNames.spotifyUri: spotifyUri}));
    if (libraryStateJson == null) {
      return null;
    }
    var libraryStateMap =
        jsonDecode(libraryStateJson) as Map<String, dynamic>;
    return LibraryState.fromJson(libraryStateMap);
  } on Exception catch (e) {
    _logException(MethodNames.getLibraryState, e);
    rethrow;
  }
}