help with android studio

Job ID: 37031853

Budget: $10 – $30 USD

I have a problem with this code:
######################################################

Widget build(BuildContext context) {
TranslateType translate = AppLocalizations.of(context)!.translate;
List<int> ids = product?.upsellIds. ?? [];
if (ids.isEmpty) {
return Container();
}
return ProductListView(
ids: ids,
keyStore: 'upsell_product',
title: translate('product_upsell'),
padding: padding,
align: align,
);
}
}
###########################################################


The problem is that when there is upsell products but they are out of stock, a block appear with the title and no products, i would like to hide it also when there is upsell products but they are out of stock. below the variables of the products:
#################################################

dynamic toVariable(String variable) {
switch (variable) {
case 'id':
return id;
case 'name':
return name;
case 'slug':
return slug;
case 'type':
return type;
case 'status':
return status;
case 'sku':
return sku;
case 'stock_status':
return stockStatus;
case 'categories':
return categories?.map((e) => '${e?.id}').toList() ?? [];
default:
return '';
}
}
###############################################

stockStatus can be 'instock' or 'outofstock'

to fix it we should verify the stockstatus of these ids

how to do it ?