mucke/lib/system/models/album_model.dart

44 lines
1.1 KiB
Dart
Raw Normal View History

2020-03-26 11:58:30 +01:00
import 'package:flutter_audio_query/flutter_audio_query.dart';
2020-03-24 22:17:03 +01:00
import 'package:meta/meta.dart';
import '../../domain/entities/album.dart';
import '../datasources/moor_music_data_source.dart';
class AlbumModel extends Album {
2020-03-26 10:19:36 +01:00
AlbumModel({
this.id,
@required String title,
@required String artist,
String albumArtPath,
int year,
}) : super(
title: title,
artist: artist,
albumArtPath: albumArtPath,
year: year,
);
2020-03-24 22:17:03 +01:00
factory AlbumModel.fromMoor(MoorAlbum moorAlbum) => AlbumModel(
2020-03-26 10:19:36 +01:00
title: moorAlbum.title,
artist: moorAlbum.artist,
albumArtPath: moorAlbum.albumArtPath,
year: moorAlbum.year,
);
2020-03-26 11:58:30 +01:00
factory AlbumModel.fromAlbumInfo(AlbumInfo albumInfo) => AlbumModel(
title: albumInfo.title,
artist: albumInfo.artist,
albumArtPath: albumInfo.albumArt,
year: int.parse(albumInfo.lastYear),
);
2020-03-26 10:19:36 +01:00
final int id;
2020-03-24 22:17:03 +01:00
MoorAlbum toMoor() => MoorAlbum(
2020-03-26 10:19:36 +01:00
title: title,
artist: artist,
albumArtPath: albumArtPath,
year: year,
);
2020-03-24 22:17:03 +01:00
}