class SearchModel { int? categoryId; int? cityId; int? page; String? searchWords; String? cityName; String? categoryName; SearchModel({this.categoryId, this.cityId, this.searchWords, this.page}); factory SearchModel.zero() => SearchModel(); Map toJson() { Map data = { if (page != null) 'page': page, if (searchWords != null) 'name': searchWords, if (categoryId != null) 'category_id': categoryId, if (cityId != null) 'city_id': cityId, }; return data; } }