// Author: fengshengxiong
// Date: 2024/6/20
// Description: Browse分组模型

import 'dart:convert';

import 'package:tone_snap/data/models/music_model.dart';

class BrowseGroupModel {
  String? groupTitle;
  String? musicType;
  List<MusicModel>? browseList;

  BrowseGroupModel({
    this.groupTitle,
    this.musicType,
    this.browseList,
  });

  factory BrowseGroupModel.fromJson(String str) => BrowseGroupModel.fromMap(json.decode(str));

  String toJson() => json.encode(toMap());

  factory BrowseGroupModel.fromMap(Map<String, dynamic> json) => BrowseGroupModel(
    groupTitle: json["groupTitle"],
    musicType: json["musicType"],
    browseList: json["browseList"] == null ? <MusicModel>[] : List<MusicModel>.from(json["browseList"]!.map((x) => MusicModel.fromMap(x))),
  );

  Map<String, dynamic> toMap() => {
    "groupTitle": groupTitle,
    "musicType": musicType,
    "browseList": browseList == null ? [] : List<dynamic>.from(browseList!.map((x) => x.toMap())),
  };
}
