SpotifyService constructor
SpotifyService({})
Implementation
SpotifyService({
required this.clientId,
required this.clientSecret,
required this.customUriScheme,
required this.redirectUri,
this.localhostPort,
}) {
// Determine redirect URI and custom URI scheme based on platform
late final String redirectUri;
late final String customUriScheme;
if (Platform.isLinux || Platform.isWindows) {
if (localhostPort == null) {
throw Exception('localhostPort is required in Linux and Windows.');
}
redirectUri = 'http://localhost:$localhostPort';
customUriScheme = 'http://localhost:$localhostPort';
} else {
redirectUri = this.redirectUri;
customUriScheme = this.customUriScheme;
}
// Initialize the OAuth2 client
client = SpotifyOAuth2Client(
redirectUri: redirectUri,
customUriScheme: customUriScheme,
);
}