Flutter API Integration – ByByBG Documentation
📱 Flutter SDK

Flutter Integration

Learn how to integrate AI background removal into Flutter Android and iOS applications using multipart image uploads and HTTP requests.

INTRODUCTION

Flutter Background Removal API

Integrate the ByByBG API into Flutter apps using multipart image uploads, HTTP requests, and AI-powered background removal workflows.

Recommended: Use secure backend proxy servers in production apps instead of exposing API keys directly inside mobile applications.
STEP 1

Install HTTP Package

Add the required HTTP dependency inside your Flutter project before making API requests.

dependencies:
  http: ^1.2.0
STEP 2

Import Required Packages

Import Dart IO and HTTP libraries before using the API request example.

import 'dart:io';

import 'package:http/http.dart'
as http;
STEP 3

Flutter API Request Example

Upload images and receive transparent PNG files using multipart HTTP requests in Flutter.

Future<void>
removeBackground(File imageFile)
async {

    var request =
    http.MultipartRequest(

        'POST',

        Uri.parse(
        'https://api.bybybg.com/v1/remove-bg'
        )

    );

    request.headers['X-API-Key'] =
    'YOUR_API_KEY';

    request.files.add(

        await http.MultipartFile
        .fromPath(
            'file',
            imageFile.path
        )

    );

    var response =
    await request.send();

    if(response.statusCode == 200){

        print(
        "Background removed"
        );

    }else{

        print(
        "Error: ${response.statusCode}"
        );

    }
}
FEATURES

Recommended Flutter Features

🖼️

Image Picker

Allow users to select images from device gallery or camera.

Progress Loader

Display animated loading indicators during AI image processing.

💾

Save PNG

Save transparent PNG files directly to mobile device storage.

🔒

Secure Backend

Protect private API keys using backend proxy servers.

BEST PRACTICES

Recommended Practices

  • Compress large images before uploading.
  • Display upload progress indicators for better UX.
  • Handle network timeouts properly.
  • Never expose private API keys publicly.
  • Cache processed images locally for better performance.
ERRORS

Common API Errors

Status
Description
401
Invalid or missing API key.
413
Uploaded image file is too large.
429
Too many requests. Rate limit exceeded.
500
Internal server processing error.

Continue to Kotlin Integration

Learn how to integrate the ByByBG API inside native Android applications using Kotlin.