getIngredientSpellingCorrection static method
Implementation
@Deprecated('Unstable version, do not use and wait for the next version')
static Future<SpellingCorrection?> getIngredientSpellingCorrection({
String? ingredientName,
Product? product,
User? user,
QueryType? queryType,
}) async {
Map<String, String> spellingCorrectionParam;
if (ingredientName != null) {
spellingCorrectionParam = {
'text': ingredientName,
};
} else if (product != null && product.barcode != null) {
spellingCorrectionParam = {
'barcode': product.barcode!,
};
} else {
return null;
}
var spellingCorrectionUri = UriHelper.getRobotoffUri(
path: 'api/v1/predict/ingredients/spellcheck',
queryType: queryType,
);
Response response = await HttpHelper().doPostRequest(
spellingCorrectionUri,
spellingCorrectionParam,
user,
queryType: queryType,
addCredentialsToBody: false,
addCredentialsToHeader: true,
);
SpellingCorrection result = SpellingCorrection.fromJson(
json.decode(utf8.decode(response.bodyBytes)));
return result;
}