fromNetwork static method

Widget fromNetwork(
  1. String? url, {
  2. double radius = 0.0,
  3. double? height,
  4. double? width,
  5. BoxFit? fit,
  6. String? placeHolder,
  7. Widget? placeHolderWidget,
  8. ImageRepeat repeat = ImageRepeat.noRepeat,
  9. FilterQuality filterQuality = FilterQuality.low,
  10. dynamic scale = 1.0,
  11. String? semanticLabel,
  12. Map<String, String>? headers,
  13. Widget loadingBuilder(
    1. BuildContext context,
    2. Widget child,
    3. ImageChunkEvent? loadingProgress
    )?,
})

Implementation

static Widget fromNetwork(
  String? url, {
  double radius: 0.0,
  double? height,
  double? width,
  BoxFit? fit,
  String? placeHolder,
  Widget? placeHolderWidget,
  ImageRepeat repeat: ImageRepeat.noRepeat,
  FilterQuality filterQuality: FilterQuality.low,
  scale: 1.0,
  String? semanticLabel,
  Map<String, String>? headers,
  Widget Function(
    BuildContext context,
    Widget child,
    ImageChunkEvent? loadingProgress,
  )?
      loadingBuilder,
}) {
  if (url == null) {
    return _setItInContainer(
        placeHolderWidget ?? Image.asset(placeHolder ?? 'assets/noimage.png'),
        width,
        height);
  }

  var image = Image.network(
    url,
    fit: fit,
    errorBuilder: (context, error, stackTrace) {
      return _setItInContainer(
          placeHolderWidget ??
              Image.asset(placeHolder ?? 'assets/noimage.png'),
          width,
          height);
    },
    headers: headers,
    scale: scale,
    height: height,
    width: width,
    repeat: repeat,
    filterQuality: filterQuality,
    semanticLabel: semanticLabel,
    loadingBuilder: loadingBuilder ??
        (context, child, loadingProgress) {
          if (loadingProgress != null &&
              loadingProgress.expectedTotalBytes != null) {
            var percent = loadingProgress.cumulativeBytesLoaded /
                loadingProgress.expectedTotalBytes!;

            return Center(
              child: CircularProgressIndicator(
                value: percent,
              ),
            );
          }
          return child;
        },
  );
  return _setItInContainer(_addRadius(image, radius), width, height);
}