fromNetwork static method
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,
- dynamic scale = 1.0,
- String? semanticLabel,
- Map<
String, String> ? headers, - Widget loadingBuilder(
- BuildContext context,
- Widget child,
- 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), width, height);
}