setAvailableVariants method Null safety

void setAvailableVariants(
  1. List<String> pixelRatios,
  2. {String defaultRatioName = ""}

Set available variants for each supported asset resolution.

pixelRatios should be provided as "3x", "1.5x"..etc. The order is irrelevant. defaultRatioName can be optionally used if you want to use a different suffix for 1.0 ratio. chooseVariant will return this value if the ratio is 1.0.,


void setAvailableVariants(List<String> pixelRatios,
    {String defaultRatioName = ""}) {
  _defaultRatioName = defaultRatioName;
  pixelRatios.forEach((element) {
    var ratio = _AssetVariantChooser._parseScale(element);
    _candidates.addEntries([MapEntry(ratio, element)]);
  if (!_candidates.containsKey(1.0)) {
    _candidates.addEntries([MapEntry(1.0, _defaultRatioName)]);