Skip to content

Commit

Permalink
Fix warnings in player models
Browse files Browse the repository at this point in the history
  • Loading branch information
rinukkusu committed Mar 16, 2023
1 parent 2dcbdc9 commit 1bdc532
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
9 changes: 0 additions & 9 deletions lib/src/models/_models.g.dart

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

23 changes: 13 additions & 10 deletions lib/src/models/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,36 +144,39 @@ class StartOrResumeOptions extends Object {
Map<String, dynamic> toJson() => _$StartOrResumeOptionsToJson(this);

static Map<String, dynamic> _offsetToJson(Offset? offset) {
if (offset is UriOffset) {
return {'uri': offset.uri};
} else if (offset is PositionOffset) {
return {'position': offset.position};
} else {
return {};
}
return offset?.toJson() ?? {};
}
}

abstract class Offset {}
abstract class Offset {
Map<String, dynamic> toJson();
}

/// "uri" is a string representing the uri of the item to start at.
/// Example: "spotify:track:1301WleyT98MSxVHPZCA6M"
@JsonSerializable()
@JsonSerializable(createFactory: false)
class UriOffset extends Offset {
final String uri;

UriOffset(this.uri);

@override
Map<String, dynamic> toJson() => _$UriOffsetToJson(this);
}

/// "position" is zero based and can’t be negative.
@JsonSerializable()
@JsonSerializable(createFactory: false)
class PositionOffset extends Offset {
final int position;

PositionOffset(this.position) {
assert(position >= 0, 'Position must be greater than or equal to 0');
}

@override
Map<String, dynamic> toJson() => _$PositionOffsetToJson(this);
}

/// Representation of the current repeat state
enum RepeatState { off, context, track }

Expand Down

0 comments on commit 1bdc532

Please sign in to comment.