diff --git a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart index 8d398d2d0..2ba50dda8 100644 --- a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart +++ b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart @@ -250,13 +250,23 @@ class _CryptoSelectionViewState extends State { } } +bool isStackCoin(String? ticker) { + if (ticker == null) return false; + + try { + coinFromTickerCaseInsensitive(ticker); + return true; + } on ArgumentError catch (_) { + return false; + } +} + Widget? getIconForTicker(String ticker) { print(ticker); - String? iconAsset = isCoinSupportedByTicker(ticker) + String? iconAsset = isStackCoin(ticker) ? Assets.svg.iconFor(coin: coinFromTickerCaseInsensitive(ticker)) : Assets.svg.buyIconFor(ticker); - if (iconAsset != null) { - return SvgPicture.asset(iconAsset, height: 20, width: 20); - } - return null; + return (iconAsset != null) + ? SvgPicture.asset(iconAsset, height: 20, width: 20) + : null; } diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index 7f130e00a..e50e51b44 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -328,29 +328,3 @@ Coin coinFromTickerCaseInsensitive(String ticker) { ticker, "name", "No Coin enum value with that ticker"); } } - -// This was added for the Buy view.I would use coinFromTickerCaseInsensitive -// however I need it to return null or something else to indicate failure -// instead of throwing an exception -bool isCoinSupportedByTicker(String ticker) { - switch (ticker.toLowerCase()) { - case "btc": - case "ltc": - case "bch": - case "doge": - case "epic": - case "firo": - case "xmr": - case "nmc": - case "part": - case "tltc": - case "tbtc": - case "tbch": - case "tfiro": - case "tdoge": - case "wow": - return true; - default: - return false; - } -}