Skip to content

Commit

Permalink
Update packages and enable null safety (#76)
Browse files Browse the repository at this point in the history
* Update Libraries and move to android embedded v2

* update packages

* downgrade pedantic

* update sdk version

* Update spotify_sdk.yml

* remove flutter upper bound

* remove unneccessary changes

* Update spotify_sdk.yml

* downgrade packages

* Update spotify_sdk.yml

* donwgrade cupertino icons

* revert changes from flutter beta

* fix dartformat

* readd automatically added changes

* Update spotify_sdk.yml

* Update spotify_sdk.yml

* update packages to null safety

* update gitignore

* extend analysis options

* add nodoc to imageextension

* update packages to the latest null safety previews

* revert sdk change

* update to null safety

* Remove dead code

* update models

* update version to use a prerelease

* Fix multiple version issue for dio

* update changelog to represent null safety

* Perform minor null safety improvements (#82)

* Upgrade gradle and remove obsolete r8

* Update Android Manifest to be android 11 ready

* Update gradle and remove unused variable on android side

* Update to latest libraries

* update dio and fix authtoken error

* Improve null-safety on the web (#85)

* Made web implementation more null-safe.

* Further null-safety improvements

* .

* Migrate to newer js library

* Fix error where the authorization screen would sometimes not communicate correctly with the plugin.

* Update pubspec.yaml

* Update changelog and readme

Co-authored-by: Foti Dim <[email protected]>
Co-authored-by: Mateusz Rębacz <[email protected]>
  • Loading branch information
3 people authored Apr 2, 2021
1 parent 49a8cd7 commit 1dbddc7
Show file tree
Hide file tree
Showing 25 changed files with 331 additions and 325 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ build/
/.vs/spotify_sdk/v16/.suo

SpotifyiOS.framework
**/doc/api/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.0
* BREAKING: opt into null safety
* upgrade Dart SDK constraints to >=2.12.0-0 <3.0.0

## 1.0.2
* fixes image dimension exception on getImage

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# spotify_sdk

[![pub package](https://img.shields.io/badge/pub-1.0.2-orange)](https://pub.dev/packages/spotify_sdk)
[![pub package](https://img.shields.io/badge/pub-2.0.0-orange)](https://pub.dev/packages/spotify_sdk)
[![build](https://github.com/brim-borium/spotify_sdk/workflows/spotify_sdk/badge.svg?branch=master)](https://github.com/brim-borium/spotify_sdk/actions?query=workflow%3Aspotify_sdk)
[![licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/IamTobi/spotify_sdk/blob/master/LICENSE)

Expand Down
9 changes: 4 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ include: package:pedantic/analysis_options.yaml
analyzer:
exclude:
# Ignore generated files
- '**/*.g.dart'
- 'lib/generated/**'
- 'lib/models/**'
- "**/*.g.dart"
- "lib/generated/**"
- "lib/models/**"
errors:
close_sinks: ignore

linter:
rules:
unsafe_html: false
unsafe_html: false
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
android:name="com.spotify.sdk.android.authentication.LoginActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>
<queries>
<package android:name="com.spotify.music" />
</queries>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ class SpotifySdkPlugin(private val registrar: Registrar) : MethodCallHandler, Pl
.setRedirectUri(redirectUrl)
.showAuthView(true)
.build()
var replySubmitted = false
SpotifyAppRemote.disconnect(spotifyAppRemote)
var initiallyConnected = false
SpotifyAppRemote.connect(registrar.context(), connectionParams,
Expand All @@ -183,7 +182,6 @@ class SpotifySdkPlugin(private val registrar: Registrar) : MethodCallHandler, Pl
connStatusEventChannel(ConnectionStatusChannel.ConnectionEvent(true, "Successfully connected to Spotify.", null, null))
// method success
result.success(true)
replySubmitted = true
}

override fun onFailure(throwable: Throwable) {
Expand Down Expand Up @@ -251,7 +249,7 @@ class SpotifySdkPlugin(private val registrar: Registrar) : MethodCallHandler, Pl

private fun getAuthenticationToken(clientId: String?, redirectUrl: String?, scope: String?, result: Result) {
if (registrar.activity() == null) {
throw IllegalStateException("connectToSpotify needs a foreground activity")
throw IllegalStateException("getAuthenticationToken needs a foreground activity")
}

if (clientId.isNullOrBlank() || redirectUrl.isNullOrBlank()) {
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
1 change: 0 additions & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class _HomeState extends State<Home> {
title: const Text('SpotifySdk Example'),
actions: [
_connected
? TextButton(
? IconButton(
onPressed: disconnect,
child: const Text('Disconnect'),
icon: Icon(Icons.exit_to_app),
)
: Container()
],
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ environment:
dependencies:
flutter:
sdk: flutter
logger: ^0.9.3
logger: ^1.0.0
flutter_dotenv: ^3.1.0
cupertino_icons: ^1.0.0

dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.9.2
pedantic: ^1.11.0
spotify_sdk:
path: ../

Expand Down
5 changes: 4 additions & 1 deletion lib/extensions/image_dimension_extension.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:spotify_sdk/enums/image_dimension_enum.dart';

///Extension for formatting the ImageDimension enum to value
///@nodoc
extension ImageDimensionExtension on ImageDimension {
///maps the value to the specified enum
///@nodoc
static const values = {
ImageDimension.large: 720,
ImageDimension.medium: 480,
Expand All @@ -12,5 +14,6 @@ extension ImageDimensionExtension on ImageDimension {
};

/// returns the value
int get value => values[this];
///@nodoc
int get value => values[this]!;
}
3 changes: 1 addition & 2 deletions lib/models/capabilities.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:flutter/foundation.dart';

part 'capabilities.g.dart';

@JsonSerializable()
class Capabilities {
Capabilities({
@required this.canPlayOnDemand,
required this.canPlayOnDemand,
});

@JsonKey(name: 'can_play_on_demand')
Expand Down
5 changes: 2 additions & 3 deletions lib/models/connection_status.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:json_annotation/json_annotation.dart';

part 'connection_status.g.dart';
Expand All @@ -9,7 +8,7 @@ class ConnectionStatus {
this.message,
this.errorCode,
this.errorDetails, {
@required this.connected,
required this.connected,
});

@JsonKey(name: 'connected')
Expand All @@ -23,7 +22,7 @@ class ConnectionStatus {

@JsonKey(ignore: true)
bool hasError() {
return errorCode?.isNotEmpty == true;
return errorCode.isNotEmpty == true;
}

factory ConnectionStatus.fromJson(Map<String, dynamic> json) =>
Expand Down
3 changes: 1 addition & 2 deletions lib/models/crossfade_state.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:flutter/foundation.dart';

part 'crossfade_state.g.dart';

@JsonSerializable()
class CrossfadeState {
CrossfadeState(
this.duration, {
@required this.isEnabled,
required this.isEnabled,
});

final bool isEnabled;
Expand Down
5 changes: 2 additions & 3 deletions lib/models/library_state.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:flutter/foundation.dart';

part 'library_state.g.dart';

@JsonSerializable()
class LibraryState {
LibraryState(
this.uri, {
@required this.isSaved,
@required this.canSave,
required this.isSaved,
required this.canSave,
});

@JsonKey(name: 'uri')
Expand Down
3 changes: 1 addition & 2 deletions lib/models/player_options.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:flutter/foundation.dart';

part 'player_options.g.dart';

@JsonSerializable()
class PlayerOptions {
PlayerOptions(
this.repeatMode, {
@required this.isShuffling,
required this.isShuffling,
});

@JsonKey(name: 'shuffle')
Expand Down
48 changes: 21 additions & 27 deletions lib/models/player_options.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions lib/models/player_restrictions.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:flutter/foundation.dart';

part 'player_restrictions.g.dart';

@JsonSerializable()
class PlayerRestrictions {
PlayerRestrictions({
@required this.canSkipNext,
@required this.canSkipPrevious,
@required this.canRepeatTrack,
@required this.canRepeatContext,
@required this.canToggleShuffle,
@required this.canSeek,
required this.canSkipNext,
required this.canSkipPrevious,
required this.canRepeatTrack,
required this.canRepeatContext,
required this.canToggleShuffle,
required this.canSeek,
});

@JsonKey(name: 'can_skip_next')
Expand Down
6 changes: 3 additions & 3 deletions lib/models/player_state.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:flutter/foundation.dart';

import 'player_options.dart';
import 'player_restrictions.dart';
import 'track.dart';
Expand All @@ -14,10 +14,10 @@ class PlayerState {
this.playbackPosition,
this.playbackOptions,
this.playbackRestrictions, {
@required this.isPaused,
required this.isPaused,
});

final Track track;
final Track? track;
@JsonKey(name: 'is_paused')
final bool isPaused;
@JsonKey(name: 'playback_speed')
Expand Down
13 changes: 4 additions & 9 deletions lib/models/player_state.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions lib/models/track.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:json_annotation/json_annotation.dart';

import 'album.dart';
Expand All @@ -17,8 +16,8 @@ class Track {
this.imageUri,
this.name,
this.uri, {
@required this.isEpisode,
@required this.isPodcast,
required this.isEpisode,
required this.isPodcast,
});

final Album album;
Expand Down
19 changes: 6 additions & 13 deletions lib/models/track.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1dbddc7

Please sign in to comment.