我有以下错误The argument type 'Widget Function(BuildContext, Widget, ImageChunkEvent)' can't be assigned to the parameter type 'Widget Function(BuildContext, Widget, ImageChunkEvent?)?'.
,我试图添加一个CircularProgressIndicator
将Image.network
在图像加载之前显示的错误。下面是我如何实现它
Padding(
padding: const EdgeInsets.all(5),
child: Builder(builder: (BuildContext context) {
if (Config().equalsIgnoreCase(
"imageNetwork", widget.imageFetchType)) {
return CircleAvatar(
radius: 100,
child: ClipOval(
child: Image.network(
widget.picture,
width: 190,
height: 190,
fit: BoxFit.cover,
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress){
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes
: null,
),
)
},
),
),
// circle avatar background color
backgroundColor: Colors.deepOrange,);
}
return CircleAvatar(
radius: 100,
backgroundImage: NetworkImage(widget.picture),
);
}),
)
错误出现在以下代码行中
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress){
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes
: null,
),
)
}
我已尝试执行以下操作,但仍然出现错误
child: (_) => Builder(builder: (BuildContext context)