call method

Future<Response> call()

Calls the Pollinations API to generate an image based on the provided prompt. @return A Future that resolves to an http.Response object with the generated image.

Implementation

Future<http.Response> call() async {
  final params = {
    "safe": safe.toString(),
    "seed": seedValue.toString(),
    "width": width.toString(),
    "height": height.toString(),
    "nologo": nologo.toString(),
    "private": private.toString(),
    "model": model,
    "enhance": enhance.toString(),
    "referrer": referrer,
  };

  final uri = Uri.parse(
    "https://${ApiConfig.getEndpoint(Api.image)}/prompt/$prompt",
  ).replace(queryParameters: params);

  final response = await http
      .get(uri, headers: ApiConfig.headers)
      .timeout(Duration(seconds: ApiConfig.timeout));
  return response;
}