toMostPlayedEntity method

MostPlayedEntity toMostPlayedEntity(
  1. int timePlayed,
  2. {int? lastTimePlayed,
  3. int? playCount}
)

Used to parse a Map into a MostPlayedEntity.

Important & Paramaters:

  • The key will be automatically generated and added.

  • If lastTimePlayed is null, will be set to DateTime.now().

  • If playCount is null, will be set to 0.

  • Only this parameters will be used used:

    • @NonNull _data
    • _display_name
    • @NonNull _id
    • album
    • album_id
    • artist
    • artist_id
    • date_added
    • duration
    • @NonNull title
    • artwork

Implementation

MostPlayedEntity toMostPlayedEntity(
  int timePlayed, {
  int? lastTimePlayed,
  int? playCount,
}) {
  lastTimePlayed ??= DateTime.now().millisecondsSinceEpoch;
  playCount ??= 0;
  return MostPlayedEntity(
      this["_id"] as int, timePlayed, lastTimePlayed, playCount)
    ..lastData = this["_data"]
    ..displayName = this["_display_name"]
    ..id = this["_id"]
    ..album = this["album"]
    ..albumId = this["album_id"]
    ..artist = this["artist"]
    ..artistId = this["artist_id"]
    ..dateAdded = this["date_added"]
    ..duration = this["duration"]
    ..title = this["title"]
    ..artworkAsBytes = this["artwork"];
}