0
_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}');
}
  1. [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FormatException: Invalid

    character (at character 1) E/flutter (27845): ‰PNG E/flutter (27845): ^

Mig82
  • 4,856
  • 4
  • 40
  • 63
farah
  • 1
  • plllllzzzzz neeeed help thats what is shows – farah Nov 18 '20 at 07:00
  • [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FormatException: Invalid character (at character 1) E/flutter (27845): PNG E/flutter (27845): ^ – farah Nov 18 '20 at 07:00
  • [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FormatException: Invalid character (at character 1) E/flutter (27845): PNG E/flutter (27845): ^ – farah Nov 18 '20 at 07:01
  • [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FormatException: Invalid character (at character 1) E/flutter (27845): PNG E/flutter (27845): ^ – farah Nov 18 '20 at 07:01

0 Answers0