setHumanDetection method

  1. @override
Future<Map<String, dynamic>> setHumanDetection(
  1. bool isEnabled
)
override

Implementation

@override
Future<Map<String, dynamic>> setHumanDetection(bool isEnabled) async {
  // if (isRequestPending) {
  //   return {
  //     "isError": true,
  //     "message": "PENDING_PREVIOUS_REQUEST",
  //     "details": "Called setHumanDetection()"
  //   };
  // }
  try {
    if (initializedCamera.isEmpty) {
      return {"isError": true, "message": "Please Login to Camera!"};
    }
    // isRequestPending = true;

    await methodChannel.invokeMethod('SET_HUMAN_DETECTION',
        {"cameraId": initializedCamera, "isEnabled": isEnabled});
    // isRequestPending = false;

    return {"isError": false};
  } catch (e) {
    // isRequestPending = false;

    if (e is PlatformException) {
      return {"isError": true, "message": e.message};
    }

    return {"isError": true, "message": "Error: $e"};
  }
}