createSrcSet method
Create a srcset given a path
and a map of params
.
This function creates a dpr based srcset if params
contain either:
- a width "w" param, or
- a height "h" and aspect ratio "ar" params
Otherwise, a srcset of width-pairs is created. path - path to the image, i.e. "image/file.png" @param params - map of query parameters @param tol - tolerable amount of width value variation @param disableVariableQuality - flag to toggle variable image
@return srcset attribute string
Implementation
// output quality.
///
/// @return srcset attribute string
///
String createSrcSet(String path,
{Map<String, String>? params,
int begin = minWidth,
int end = maxWidth,
int tol = srcsetWidthTolerance,
bool disableVariableQuality = false,
Iterable<int>? targets}) {
final srcsetParams = SplayTreeMap<String, String>.of(params ?? {});
if (targets?.isNotEmpty == true) {
return createSrcSetPairs(path, srcsetParams, targets!);
} else if (isDpr(srcsetParams)) {
return createSrcSetDPR(path, srcsetParams, disableVariableQuality);
} else {
var targets = targetWidths(begin, end, tol);
return createSrcSetPairs(path, srcsetParams, targets);
}
}