utilNetworkImage static method

CachedNetworkImage utilNetworkImage(
  1. String url, {
  2. BoxFit? fit = BoxFit.cover,
})

网络图片

Implementation

static CachedNetworkImage utilNetworkImage(String url,{BoxFit? fit=BoxFit.cover,}) {
  return CachedNetworkImage(
    fit: fit,
    imageUrl: url,
    placeholder: (context, url) {
      return Container(
        alignment: Alignment.center,
        color: Colors.red,
      );
    },
    errorWidget: (context, url, error) => Center(
      child: Expanded(
        flex: 1,
        child: Container(
          color: Colors.red,
        ),
      ),
    ),
  );
}