getUri static method

Uri getUri({
  1. required String path,
  2. Map<String, String>? queryParameters,
  3. QueryType? queryType,
  4. bool addUserAgentParameters = true,
  5. String? userInfo,
})

Returns a OFF uri with the OpenFoodAPIConfiguration specified settings

Typical use-case of "addUserAgentParameters = false" is for other request than GET, e.g. POST or MULTIPART, where we add the user agent parameters in another part of the code.

Implementation

static Uri getUri({
  required final String path,
  final Map<String, String>? queryParameters,
  final QueryType? queryType,
  final bool addUserAgentParameters = true,
  final String? userInfo,
}) =>
    Uri(
      scheme: OpenFoodAPIConfiguration.uriScheme,
      host: OpenFoodAPIConfiguration.getQueryType(queryType) == QueryType.PROD
          ? OpenFoodAPIConfiguration.uriProdHost
          : OpenFoodAPIConfiguration.uriTestHost,
      path: path,
      queryParameters: addUserAgentParameters
          ? HttpHelper.addUserAgentParameters(queryParameters)
          : queryParameters,
      userInfo: userInfo,
    );