i use woocommerce rest api with flutter to get product variations. Woocommerce rest api is too slowly to get this variations. I need to send a message to the user to wait for the process to finish. How to put this message in the code?
@override
Future<List<ProductVariation>> getProductVariations(Product product,
{String lang = 'en'}) async {
try {
final List<ProductVariation> list = [];
int page = 1;
while (true) {
String endPoint =
"products/${product.id}/variations?per_page=100&page=$page";
if (kAdvanceConfig["isMultiLanguages"]) {
endPoint += "&lang=$lang";
}
var response = await wcApi.getAsync(endPoint);
if (response is Map && isNotBlank(response["message"])) {
throw Exception(response["message"]);
} else {
if (response is List && response.isEmpty) {
/// No more data.
break;
}
for (var item in response) {
if (item['visible']) {
list.add(ProductVariation.fromJson(item));
}
}
/// Fetch next page.
page++;
}
}
return list;
} catch (e) {
//This error exception is about your Rest API is not config correctly so that not return the correct JSON format, please double check the document from this link https://docs.inspireui.com/fluxstore/woocommerce-setup/
rethrow;
}
}
Any help?