'Multiple if statements in a flutter image widget
Solution 1:[1]
you are using the tenary expression too complicated, i would suggest you to use function instead:
String _cryptoImage(String cryptoName){
String imageUrl = coinList[3].imageUrl;
if(cryptoName == 'btc') imageUrl = coinList[0];
else if(cryptoName == 'eth') imageUrl = coinList[1];
return imageUrl;
}
CachedNetworkImage(
imageUrl: _cryptoImage(ownedCryptoDB[index])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jim |

