getLicenseProducts method
Retrieves the license products associated with a given document.
This method sets the document products using a native method call and then
retrieves the product list if the document is successfully set. The result
is wrapped in an Either type, where the left side represents an error
message and the right side represents the successful response.
Parameters:
document: The document identifier for which the license products are to be retrieved.
Returns:
A Future that resolves to an Either containing a String error message
on the left side or a dynamic response on the right side.
Implementation
Future<Either<String, dynamic>> getLicenseProducts({
required String document,
}) async {
final response =
await invokeNativeMethod('SmartfaceLicense.setDocumentProducts', {
'arg0': document,
});
return response.match(
(error) => Left(error),
(success) async {
if (!success) {
return const Left('Failed to set document');
}
await _secureStorageWrite(
key: 'document',
value: document,
);
if (Platform.isIOS) {
// Need String 'arg0' document. -> SmartfaceLicense.getProductList (arg0)
return await invokeNativeMethod('SmartfaceLicense.getProductList', {
'arg0': document,
});
}
return await invokeNativeMethod('SmartfaceLicense.getProductList');
},
);
}