start static method
Starts the document capture process and retrieves the parsed result.
Parameters:
- hvDocConfig (optional): An instance of HVDocConfig representing the document capture configuration.
- onComplete: A callback function of type Function(HVResponse?, HVError?) that will be called when the capture process is complete.
The onComplete
function should handle the resulting HVResponse and HVError.
Example usage:
HVDocsCapture.start(
hvDocConfig: HVDocConfig(),
onComplete: (response, error) {
// Handle the response and error here
},
);
Implementation
static Future<void> start({
HVDocConfig? hvDocConfig,
required Function(HVResponse?, HVError?) onComplete,
}) async {
try {
final resMap = await _hyperSnapSDKChannel.invokeMethod(
HyperSnapSDKConstants.startDocCapture,
{
HyperSnapSDKConstants.docConfig:
hvDocConfig?.toMap() ?? HVDocConfig().toMap(),
},
);
final errorObj = resMap["errorObj"];
final resObj = resMap["resultObj"];
final hvError = (errorObj.isEmpty) ? null : HVError.fromMap(errorObj);
final hvResponse = (resObj.isEmpty) ? null : HVResponse.fromMap(resObj);
onComplete(hvResponse, hvError);
} catch (e) {
log(e.toString());
}
}