MessageSearchRequest constructor Null safety

MessageSearchRequest(
  1. {required String keyword,
  2. String? channelUrl,
  3. String? customType,
  4. String? beforeIndex,
  5. String? afterIndex,
  6. String? token,
  7. List<String>? targetUserIds,
  8. int? startAt,
  9. int? endAt,
  10. String? sortField,
  11. int? limit,
  12. bool? reverse,
  13. bool? exactMatch,
  14. bool? advanced,
  15. List<String>? targetFields}
)

Implementation

MessageSearchRequest({
  required String keyword,
  String? channelUrl,
  String? customType,
  String? beforeIndex,
  String? afterIndex,
  String? token,
  List<String>? targetUserIds,
  int? startAt,
  int? endAt,
  String? sortField,
  int? limit,
  bool? reverse,
  bool? exactMatch,
  bool? advanced,
  List<String>? targetFields,
}) : super() {
  url = 'search/messages';
  queryParams = {
    'query': keyword,
    'channel_url': channelUrl,
    'custom_type': customType,
    'limit': limit,
    'before': beforeIndex,
    'after': afterIndex,
    'token': token,
    'target_user_ids': targetUserIds,
    'include_open': false,
    'include_not_joined_public': false,
    'sort_field': sortField,
    'reverse': reverse,
    'exact_match': exactMatch,
    'advanced_query': advanced,
    'target_fields': targetFields,
    if (startAt != 0) 'message_ts_from': startAt,
    if (endAt != 0) 'message_ts_to': endAt,
  };

  queryParams.removeWhere((key, value) => value == null);
}