init method

  1. @override
Widget init(
  1. BuildContext context
)
override

Implementation

@override
Widget init(BuildContext context) {
  double? width = this.width;

  if (style != null) {
    width = width ?? style?.width ?? this.width;
  }

  width = width ?? double.infinity;

  if (image == '') {
    return SizedBox(width: width, height: height);
  }

  final fit = this.fit ?? BoxFit.cover;

  Widget widget;

  if (errorImage.isNotEmpty) {
    widget = CachedNetworkImage(
      width: width,
      height: height,
      fit: fit,
      imageUrl: image,
      errorWidget: (context, url, error) =>
          Image.asset(errorImage, width: width, height: height),
    );
  } else {
    widget = CachedNetworkImage(
      width: width,
      height: height,
      fit: fit,
      imageUrl: image,
    );
  }

  if (hero != null && hero!.isNotEmpty) {
    widget = Hero(tag: '$hero $image', child: widget);
  }

  return widget;
}