imageNetwork function
Widget
imageNetwork(
- String url, {
- Color? color,
- double? width,
- double? height,
- BoxFit fit = BoxFit.contain,
- Clip clipBehavior = Clip.hardEdge,
- double borderRadius = 1,
- EdgeInsets margin = EdgeInsets.zero,
- VoidCallback? onTap,
- String? placeholder,
Implementation
Widget imageNetwork(
final String url, {
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,
final String? placeholder,
}) =>
GestureDetector(
onTap: onTap,
child: Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(borderRadius)),
margin: margin,
width: width,
height: height,
child: url.length <= 10
? placeholder == null
? const SizedBox()
: imageAsset(
placeholder,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
)
: url.substring(url.length - 3) == "svg"
? SvgPicture.network(
url,
color: color,
width: width,
height: height,
fit: fit,
placeholderBuilder: placeholder == null
? null
: (final _) => imageAsset(
placeholder,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
),
)
: CachedNetworkImage(
imageUrl: url,
color: color,
width: width,
height: height,
fit: fit,
errorWidget: placeholder == null
? null
: (final _, final __, final ___) => imageAsset(
placeholder,
color: color,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
),
placeholder: placeholder == null
? null
: (final _, final __) => imageAsset(
placeholder,
color: color,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
),
),
),
);