buildTopHeadlinesUrl static method

String buildTopHeadlinesUrl(
  1. String? country,
  2. String? category,
  3. String? sources,
  4. String? query,
  5. int? pageSize,
  6. int? page,
)

Implementation

static String buildTopHeadlinesUrl(
  String? country,
  String? category,
  String? sources,
  String? query,
  int? pageSize,
  int? page,
) {
  final Uri url = Uri.parse("top-headlines?x=y");
  final queryParams = <String, String>{};
  if (country != null) queryParams["country"] = country;
  if (category != null) queryParams["category"] = category;
  if (sources != null) queryParams["sources"] = sources;
  if (query != null) queryParams["q"] = query;
  if (pageSize != null) queryParams["pageSize"] = pageSize.toString();
  if (page != null) queryParams["page"] = page.toString();
  return url.replace(queryParameters: queryParams).toString();
}