_asyncMethod() async {
ByteData bytes = await rootBundle.load('assets/images/technology.jpg');
var buffer = bytes.buffer;
var m = base64.encode(Uint8List.view(buffer));
final body = {"image_file_b64": m, "size": "auto"};
final headers = {"X-API-Key": "xxxxxxxxxxxxxxxxxxxx"};
final response = await http.post('https://api.remove.bg/v1.0/removebg',
body: body, headers: headers);
if (response.statusCode == 200) {
responseBody = response.body;
var jsonResponse = convert.jsonDecode(response.body);
debugPrint("$jsonResponse");
//var itemCount = jsonResponse['data'];
// ignore: unnecessary_statements
} else {
throw Exception(
'Failed to do network requests: Error Code: ${response.statusCode}\nBody: ${response.body}');
}
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FormatException: Invalid
character (at character 1) E/flutter (27845): ‰PNG E/flutter (27845): ^