getImages method

dynamic getImages(
  1. String url
)

get avaiable images for a url from pixabay

Implementation

getImages(String url) async {
  // setup Http Get
  HttpClient httpClient = HttpClient();
  HttpClientRequest request = await httpClient.getUrl(Uri.parse(url));
  HttpClientResponse response = await request.close();
  // Process the response.

  print(response.headers);

  if (response.statusCode == 200) {
    // response: OK
    // decode JSON
    String json = await utf8.decoder.bind(response).join();
    return json;
  } else {
    // something went wrong :(
    print("Http error: ${response.statusCode}");
    return [];
  }
}