MediaBuilderDetail.fromJson constructor
MediaBuilderDetail.fromJson(
- Map<String, dynamic> json
)
Implementation
factory MediaBuilderDetail.fromJson(Map<String, dynamic> json) {
final tagsJson = json['tags'] as String? ?? '{}';
final metadataJson = json['metadata'] as String? ?? '{}';
final tags = (jsonDecode(tagsJson) as Map<String, dynamic>)
.map((key, value) => MapEntry(key, value.toString()));
final metadata = (jsonDecode(metadataJson) as Map<String, dynamic>)
.map((key, value) => MapEntry(key, value.toString()));
return MediaBuilderDetail(
id: json['id'] as String? ?? '',
filePath: json['filePath'] as String? ?? '',
fileType: json['fileType'] as String? ?? '',
createdAt: json['createdAt'] as String?,
updatedAt: json['updatedAt'] as String?,
tags: tags,
metadata: metadata,
durationMilliseconds: json['durationMilliseconds'] == 'nil' ||
json['durationMilliseconds'] == 'null'
? '0'
: json['durationMilliseconds'] as String? ?? '0',
remoteId: json['remoteId'] as String?,
remoteURL: json['remoteURL'] as String?,
transcriptionURL: json['transcriptionURL'] as String?,
transcriptionLength: json['transcriptionLength'] as String? ?? '0.0',
status: (json['status'].runtimeType == int)
? json['status'].toString()
: json['status'].toString(),
progress: json['progress'].runtimeType == String
? double.tryParse(json['progress'].toString()) ?? 0.0
: (json['progress'] as num?)?.toDouble() ?? 0.0,
);
}