buildEverythingUrl static method

String buildEverythingUrl(
  1. String? query,
  2. String? queryInTitle,
  3. String? sources,
  4. String? domains,
  5. String? excludeDomains,
  6. DateTime? from,
  7. DateTime? to,
  8. String? language,
  9. String? sortBy,
  10. int? pageSize,
  11. int? page,
)

Implementation

static String buildEverythingUrl(
  String? query,
  String? queryInTitle,
  String? sources,
  String? domains,
  String? excludeDomains,
  DateTime? from,
  DateTime? to,
  String? language,
  String? sortBy,
  int? pageSize,
  int? page,
) {
  final Uri url = Uri.parse("everything?x=y");
  final queryParams = <String, String>{};
  if (query != null) queryParams["q"] = query;
  if (queryInTitle != null) queryParams["qInTitle"] = queryInTitle;
  if (sources != null) queryParams["sources"] = sources;
  if (domains != null) queryParams["domains"] = domains;
  if (excludeDomains != null) queryParams["excludeDomains"] = excludeDomains;
  if (from != null) queryParams["from"] = Util.formatDate(from);
  if (to != null) queryParams["to"] = Util.formatDate(to);
  if (language != null) queryParams["language"] = language;
  if (sortBy != null) queryParams["sortBy"] = sortBy;
  if (pageSize != null) queryParams["pageSize"] = pageSize.toString();
  if (page != null) queryParams["page"] = page.toString();
  return url.replace(queryParameters: queryParams).toString();
}