Is it possible to develop an app using the remove.bg API in Flutter?

Question:

  • I got an API called remove.bg . I want to use this API ( provided in python language ) in my Flutter App. Is it even possible?

  • This API uses for removing image background.

  • What are the steps/ research I need to do to get this thing working?

  • Do lots of Googling, but ends up with nothing.

Really Appreciate your help!!!

  • OR can I use this link and able to upload and get the output in my app?

for example, I open the APP, and it will show two-button -> Upload image & download image.

when user clicks the Upload button it will redirect to this link and after processing done in the website, the output we can able to download in our app.

Asked By: Tuhin

||

Answers:

This is possible with Flutter’s http package. Assuming it is some form of RESTful API this should give you a starting point:

final body = {"image_file": "@/path/to/file.jpg", "size": "auto"};
final headers = {"X-API-Key": INSERT_YOUR_API_KEY_HERE};
final response = await http.post('https://api.remove.bg/v1.0/removebg', 
  body: body,
  headers: headers);

if (response.statusCode == 200) {
      // do something with response.body
    } else {
      throw Exception('Failed to do network requests: Error Code: ${response.statusCode}nBody: ${response.body}');
    }

A good tutorial on http in Flutter is here.


Note: You may have to do json.encode(body) and the same with header and use json.decode(response.body) depending on the API.

Hope it helps, and if so please up vote and accept as answer and if not please leave a comment below.

Answered By: Gabe
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.