ChapterInfo.fromJson constructor

ChapterInfo.fromJson(
  1. Map<String, dynamic> json
)

从 JSON 映射创建 ChapterInfo 实例

Create a ChapterInfo instance from a JSON map

Implementation

factory ChapterInfo.fromJson(Map<String, dynamic> json) {
  final startMs = (json['startMs'] as num?)?.toInt() ?? 0;
  final endMs = (json['endMs'] as num?)?.toInt() ?? startMs;

  return ChapterInfo(
    id: json['id'] as String?,
    startMs: startMs,
    endMs: endMs,
    title: json['title'] as String? ?? '',
    thumbnailUrl: json['thumbnailUrl'] as String?,
  );
}