utilNetworkImage_imageBuilder static method

Widget utilNetworkImage_imageBuilder(
  1. String url, {
  2. BoxFit? fit = BoxFit.cover,
  3. Widget imageBuilder(
    1. BuildContext,
    2. ImageProvider<Object>
    )?,
})

网络图片

Implementation

static Widget utilNetworkImage_imageBuilder(
  String url, {
  BoxFit? fit = BoxFit.cover,
  Widget Function(BuildContext, ImageProvider<Object>)? imageBuilder,
}) {
  if (FFEmpty.stringIsEmpty(url) || !url.startsWith("http")) {
    return _failWidget();
  }

  try {
    return CachedNetworkImage(
      fit: fit,
      imageUrl: url,
      placeholder: (context, url) {
        return _placeholderWidget();
      },
      errorWidget: (context, url, error) {
        return _failWidget();
      },
      imageBuilder: imageBuilder,
    );
  } catch (e) {
    print("FFImageUtil load image error");
  }

  return _failWidget();
}