可自定义加载时占位图片和加载失败时展示的图片
class ImageBuildView extends StatelessWidget { String ? url; double radius; double? width; double? height; String placeholder; ImageBuildView ( { super . key, this . url, this . width, this . height, this . radius = 50 , this . placeholder = "assets/images/loading.png" } ) ; @override Widget build ( BuildContext context) { return ClipRRect ( borderRadius: BorderRadius . circular ( radius) , child: FadeInImage . assetNetwork ( placeholder: placeholder, image: url != null && url! . isNotEmpty ? " ${ Api . BASE_URL} / $ url " : '' , fit: BoxFit . cover, width: width ? ? 60. w, height: height ? ? 60. w, imageErrorBuilder: ( context, error, stackTrace) { return Center ( child: Image . asset ( "assets/images/image_error.png" , width: ( width ? ? 60. w) - 20. w, height: ( height ? ? 60. w) - 20. w) , ) ; } , ) , ) ; }
}