imageAsset function
Widget
imageAsset(
- String asset, {
- Color? color,
- double? width,
- double? height,
- BoxFit fit = BoxFit.contain,
- Clip clipBehavior = Clip.hardEdge,
- double borderRadius = 1,
- EdgeInsets margin = EdgeInsets.zero,
- VoidCallback? onTap,
Implementation
Widget imageAsset(
final String asset, {
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 VoidCallback? onTap,
}) =>
GestureDetector(
onTap: onTap,
child: Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(borderRadius)),
margin: margin,
width: width,
height: height,
child: asset.substring(asset.length - 3).toLowerCase() == "svg"
? SvgPicture.asset(
asset,
color: color,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
)
: Image.asset(asset, color: color, width: width, height: height, fit: fit),
),
);