import 'package:flutter/material.dart'; import 'prank_sound.dart'; class PrankCategory { final String categoryId; final String categoryName; final String categoryUrl; final List list; final Color themeColor; PrankCategory({ required this.categoryId, required this.categoryName, required this.categoryUrl, required this.list, this.themeColor = const Color(0xFF6C63FF), }); factory PrankCategory.fromJson(Map json, int index) { final List colors = [ const Color(0xFF6C63FF), // Purple const Color(0xFFFF6584), // Pink const Color(0xFF32D74B), // Green const Color(0xFFFF9F0A), // Orange const Color(0xFF30B0C7), // Teal const Color(0xFFFF453A), // Red ]; var listData = json['list'] as List? ?? []; List soundList = listData.map((i) => PrankSound.fromJson(i)).toList(); return PrankCategory( categoryId: json['categoryId'] ?? '', categoryName: json['categoryName'] ?? 'Category', categoryUrl: json['categoryUrl'] ?? '', list: soundList, themeColor: colors[index % colors.length], ); } }