TKeyValue.image constructor
TKeyValue.image(})
Creates a key-value item for displaying an image using TImage.
Implementation
factory TKeyValue.image(
String key,
String? url, {
Uint8List? bytes,
double size = 40.0,
double? imageWidth,
double? imageHeight,
BoxFit fit = BoxFit.cover,
BorderRadius? borderRadius,
bool forceCache = false,
Widget? icon,
double? width,
Alignment? alignment,
double? minWidth,
double? maxWidth,
}) {
Widget? widget;
final hasUrl = url != null && url.isNotEmpty;
final hasBytes = bytes != null && bytes.isNotEmpty;
if (hasUrl || hasBytes) {
widget = TImage(
url: url,
bytes: bytes,
size: (imageWidth == null && imageHeight == null) ? size : null,
width: imageWidth,
height: imageHeight,
fit: fit,
border: borderRadius != null
? RoundedRectangleBorder(borderRadius: borderRadius)
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(6))),
forceCache: forceCache,
);
}
return TKeyValue(
key,
value: widget == null ? (url ?? '') : null,
widget: widget,
icon: icon,
width: width,
alignment: alignment,
minWidth: minWidth,
maxWidth: maxWidth,
);
}