verificationCheck method

Future<Liveness> verificationCheck(
  1. dynamic file
)

Implementation

Future<Liveness> verificationCheck(file) async {
  // print(" //// imageRecognition/liveliness ///");
  //print(base64File);
  //print(base64File.length);
  //print('fileName=$fileName');

  var postData = {
    "file": file,
    "image_id":"${DateTime.now().microsecond}"
    //"image_id": '10'
  };
  // var postData = {"file": base645, "image_id": DateTime.now().microsecond};
  //   Logger().i(postData);
  // Logger().i(file.toString().length);
  // Logger().i(base645.length);
  // var url = Uri.https(baseUrl1, '/api/sdk/v1/upload');
  try {
    //var url = Uri.https(baseUrl1, 'imageRecognition/liveliness');
    var url = Uri.https(baseUrl1, '/sdk-api/v1/imageRecognition/liveliness');
   /// var url = Uri.https(baseUrl1, '/api/sdk/v1/imageRecognition/liveliness');

    ///https://test.instafido.com/api/sdk/v1/imageRecognition/liveliness
    // Await the http get response, then decode the json-formatted response.
  //  Logger().i(url);
    var response = await http.post(url, body: postData, headers: {
      "document-access-token": accessToken,
      //"content-Type": 'application/json'
    });
    // print('*******************************************************************************');
    //print(' ////////////// =${response.body}');
    // print('*******************************************************************************');
    //  Logger().i(response.statusCode.toString());
    if (response.statusCode == 200) {
     // Logger().i(response.body.toString());
      return Liveness.fromJson(response.body.toString());
    } else {
      //return "";
      showErrorToast(
        "Something went wrong,please try ",
      );
      throw Exception();
    }
  } on TimeoutException catch (e) {
   // print('Timeout Error: $e');
    showErrorToast(
      "Connection timeout, please try again",
    );
    throw Exception();
  } on SocketException catch (e) {
   // print('Socket Error: $e');
    showErrorToast(
      "Please check your network connection",
    );
    throw Exception();
  } on Error catch (e) {
   print('General Error: $e');
    showErrorToast(
      "Something went wrong",
    );
    throw Exception();
  }
}