image function
Widget
image(
- String source, {
- Color? color,
- double? width,
- double? height,
- BoxFit fit = BoxFit.contain,
- Clip clipBehavior = Clip.hardEdge,
- double borderRadius = 1,
- EdgeInsets margin = EdgeInsets.zero,
- String? placeholder,
- VoidCallback? onTap,
Implementation
Widget image(
final String source, {
final Color? color,
final double? width,
final double? height,
final BoxFit fit = BoxFit.contain,
final Clip clipBehavior = Clip.hardEdge,
final double borderRadius = 1,
final EdgeInsets margin = EdgeInsets.zero,
final String? placeholder,
final VoidCallback? onTap,
}) {
if (source.length <= 10) {
if (placeholder == null)
return SizedBox(width: width, height: height);
else
return imageAsset(
placeholder,
width: width,
height: height,
borderRadius: borderRadius,
color: color,
margin: margin,
onTap: onTap,
fit: fit,
clipBehavior: clipBehavior,
);
} else {
if (source.contains("http://") || source.contains("https://"))
return imageNetwork(
source,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
margin: margin,
borderRadius: borderRadius,
color: color,
onTap: onTap,
placeholder: placeholder,
);
else
return imageAsset(
source,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
margin: margin,
borderRadius: borderRadius,
color: color,
onTap: onTap,
);
}
}