55 lines
1.0 KiB
Dart
55 lines
1.0 KiB
Dart
// Author: fengshengxiong
|
|
// Date: 2024/6/4
|
|
// Description: 音频实体类
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
part 'voice_model.g.dart';
|
|
|
|
VoiceModel voiceModelFromJson(String str) => VoiceModel.fromJson(json.decode(str));
|
|
|
|
String voiceModelToJson(VoiceModel data) => json.encode(data.toJson());
|
|
|
|
@HiveType(typeId: 0)
|
|
class VoiceModel extends HiveObject {
|
|
@HiveField(0)
|
|
String name;
|
|
|
|
@HiveField(1)
|
|
String path;
|
|
|
|
@HiveField(2)
|
|
String? cover;
|
|
|
|
VoiceModel({
|
|
required this.name,
|
|
required this.path,
|
|
this.cover,
|
|
});
|
|
|
|
VoiceModel copyWith({
|
|
String? name,
|
|
String? path,
|
|
String? cover,
|
|
}) =>
|
|
VoiceModel(
|
|
name: name ?? this.name,
|
|
path: path ?? this.path,
|
|
cover: cover ?? this.cover,
|
|
);
|
|
|
|
factory VoiceModel.fromJson(Map<String, dynamic> json) => VoiceModel(
|
|
name: json["name"],
|
|
path: json["path"],
|
|
cover: json["cover"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"name": name,
|
|
"path": path,
|
|
"cover": cover,
|
|
};
|
|
}
|