getImageTryOnResponse function

Future<String> getImageTryOnResponse(
  1. String imagePath,
  2. String imageId
)

Implementation

Future<String> getImageTryOnResponse(String imagePath, String imageId) async {
  var url = Uri.parse('https://api.hair.mirrar.io/tryon/');

  var request = http.MultipartRequest('POST', url);
  request.fields['hairstyle_image_path'] = imagePath;
  request.fields['user_image_id'] = userImageId;

  var response = await request.send();

  if (response.statusCode == 200) {
    String responseString =
        await response.stream.transform(utf8.decoder).join();
    print("checkMessage $responseString");
    return responseString;
  } else {
    print('Request failed with status: ${response.statusCode}');
    throw Exception('API call failed with status: ${response.statusCode}');
  }
}