api method

Uri api(
  1. String method, [
  2. Map<String, dynamic> params = const {}
])

Implementation

Uri api(String method, [Map<String, dynamic> params = const {}]) {
  Map<String, String> queryParams =
      params.map((key, value) => MapEntry(key, value.toString()));
  bool hasParams = queryParams.length > 0;
  if (SSL) {
    Uri? uriResult;
    if (hasParams) {
      uriResult = Uri.https(url, 'api/$method', queryParams);
    } else {
      uriResult = Uri.https(url, 'api/$method');
    }
    return uriResult;
  } else {
    return Uri.http(url, 'api/$method', queryParams);
  }
}