toUri static method

Uri toUri({
  1. Object? getParams,
  2. String? baseUrl = '',
})

Converts getParams object to Uri GET request with baseUrl

Implementation

static Uri toUri({Object? getParams, String? baseUrl = ''}) {
  final params = _jsonDecoder
      .convert(serialize(getParams))
      ?.entries
      .map((e) => e.key + '=' + Uri.encodeQueryComponent(e.value.toString()))
      .join('&');
  return Uri.parse('$baseUrl${params != null ? '?$params' : ''}');
}