updateCoin method

void updateCoin(
  1. String coinSymbol,
  2. String coinPrice,
  3. String coinPercentage
)

update coin

Implementation

void updateCoin(
    String coinSymbol, String coinPrice, String coinPercentage) async {
  var inrPairCoins = coinSymbol.substring(0, coinSymbol.length - 4);

  var index = allCoinsList.where((element) =>
      element.symbol.toUpperCase() == coinSymbol.toUpperCase() ||
      element.symbol.toUpperCase() == '${inrPairCoins.toUpperCase()}INR');
  var selectedCurrencyIndex = selectedCurrencyCoins.where((element) =>
      element.symbol.toUpperCase() == coinSymbol.toUpperCase() ||
      element.symbol.toUpperCase() == '${inrPairCoins.toUpperCase()}INR');
  var wishlistIndex = wishlistCoinsList.where(
      (element) => element.symbol.toUpperCase() == coinSymbol.toUpperCase());

  for (var i in index) {
    i.price = coinPrice;
    i.percentage = coinPercentage;
  }

  for (var i in selectedCurrencyIndex) {
    i.price = coinPrice;
    i.percentage = coinPercentage;
  }

  for (var i in wishlistIndex) {
    i.price = coinPrice;
    i.percentage = coinPercentage;
  }

  update();
}