updateValue method

void updateValue(
  1. String id,
  2. double price, {
  3. String? extraPrice,
})

API to update price.

currencyCode + price will appear on custom payment sheet. If price is set, then extraPrice is initialized empty value, because extraPrice appear if extraPrice is not empty.

Parameters: id - Unique ID of item to update. price - Price to be set.

Exceptions: Throws an ArgumentError if the ID is empty. Throws an ArgumentError if there are no items associated with the ID.

Implementation

void updateValue(String id, double price,{String? extraPrice}){

  if (id.isEmpty) {
    throw ArgumentError("You must set itemId.");
  }
  int foundIndex = _getItemIndex(id);
  if (foundIndex > -1) {
    if(extraPrice==null)
    {
      SheetItem item = SheetItem(id: id, title: items![foundIndex].title, dValue: price,  sValue: "", sheetItemType: items![foundIndex].getSheetItemType());
      items?[foundIndex] = item;
    }
    else
    {
      SheetItem item = SheetItem(id: id, title: items![foundIndex].title, dValue: price, sValue: extraPrice,  sheetItemType: items![foundIndex].getSheetItemType());
      items?[foundIndex] = item;
    }
    return;
  }
  throw ArgumentError("updateValue : there are no items associated with the id.");//popup
}