// To parse this JSON data, do // // final serverEntity = serverEntityFromMap(jsonString); import 'dart:convert'; List serverEntityFromList(List data) => List.from(data.map((x) => ServerEntity.fromMap((x)))); class ServerEntity { ServerEntity({ required this.id, required this.groupId, required this.parentId, required this.tags, required this.name, required this.rate, required this.host, required this.port, required this.serverPort, required this.cipher, required this.show, required this.sort, required this.createdAt, required this.updatedAt, required this.type, required this.lastCheckAt, }); final int id; final List groupId; final int? parentId; final List tags; final String name; final String rate; final String host; final int port; final int serverPort; final String cipher; final int show; final int sort; Duration? ping; final int createdAt; final int updatedAt; final String type; final String lastCheckAt; factory ServerEntity.fromJson(String str) => ServerEntity.fromMap(json.decode(str)); String toJson() => json.encode(toMap()); factory ServerEntity.fromMap(Map json) => ServerEntity( id: json["id"], groupId: List.from(json["group_id"]?.map((x) => x) ?? []), parentId: json["parent_id"], tags: List.from(json["tags"]?.map((x) => x) ?? []), name: json["name"] ?? "", rate: json["rate"], host: json["host"] ?? "", port: int.parse(json["port"] ?? "0"), serverPort: int.parse(json["server_port"] ?? "0"), //json["server_port"], cipher: json["cipher"] ?? "", show: json["show"] ?? 0, sort: json["sort"] ?? 0, createdAt: json["created_at"] ?? 0, updatedAt: json["updated_at"] ?? 0, type: json["type"], lastCheckAt: "", //json["last_check_at"] + ); Map toMap() => { "id": id, "group_id": List.from(groupId.map((x) => x)), "parent_id": parentId, "tags": List.from(tags.map((x) => x)), "name": name, "rate": rate, "host": host, "port": port, "server_port": serverPort, "cipher": cipher, "show": show, "sort": sort, "created_at": createdAt, "updated_at": updatedAt, "type": type, "last_check_at": lastCheckAt, }; }