Map<String, dynamic> toJson() { return { 'id': id, 'key': key, 'value': value, if (type != null) 'type': type, }; }