/* - GEOSITE,geolocation-!cn,proxy - GEOSITE,cn,DIRECT - GEOIP,CN,DIRECT - MATCH,proxy */ class Rule { final String type; final String? condition; final String action; Rule({ required this.type, this.condition, required this.action, }); factory Rule.fromMap(Map map) { return Rule( type: map['type'], condition: map['condition'], action: map['action'], ); } Map toJson() { return { 'type': type, 'condition': condition, 'action': action, }; } String toYaml() { // 当 condition 不为空时,包括 condition,否则省略 condition String conditionPart = condition != null ? ',$condition' : ''; return ' - $type$conditionPart,$action'; } }