assemblyTx method
String
assemblyTx({
- required String url,
- required double width,
- double height = 0,
- ImageCutGravity cutGravity = ImageCutGravity.center,
- ImageCutType cutType = ImageCutType.rradius,
- double radius = 2,
- ZoomType zoomType = ZoomType.geometric,
配置图片url
png图片时圆角裁剪无效
url
原图片地址
width
图片宽度(必填项)
height
图片高度(裁剪时需要)
cutGravity
图片裁剪对齐参考点(isPortrait==true时该参数无效),默认以center为参考点;
cutType
裁剪方式,默认为圆角裁剪
radius
裁剪半径、圆角半径;(默认为2,方便图片圆角半径参数设置)
zoomType
缩放类型与裁剪有关,当zoomType==ZoomType.geometric时cutType和cutGravity无效;
Implementation
String assemblyTx({
required String url,
required double width,
double height = 0,
ImageCutGravity cutGravity = ImageCutGravity.center,
ImageCutType cutType = ImageCutType.rradius,
double radius = 2,
ZoomType zoomType = ZoomType.geometric,
}) {
var type = _checkUrl(url);
if (type == 2) {
return url;
} else if (type == 3) {
var index = url.indexOf("?");
url = url.substring(0, index);
}
if (url.suffixName == "gif") {
return url;
}
var pixelRatio = MediaUtils.instance.pixelRatio;
if (pixelRatio < 1) {
pixelRatio = 1;
} else {
pixelRatio = pixelRatio * 1.2;
}
return _cutZoomAssembly(
url: url,
width: width * pixelRatio,
height: height * pixelRatio,
cutGravity: cutGravity,
cutType: cutType,
radius: radius,
zoomType: zoomType);
}