如何验证Image.Network?

时间:2019-05-15 12:22:47

标签: dart flutter

我从api请求了图片,有时用户没有员工图片。如何设置默认图像如果请求图像为空?

try {
      return Image.network(
        "$_url/nativeapi/v1.0/s3object/GetEmployeeImage?siteId=${widget
            .siteId}&employeeId=${widget.employeeId}",
        width: 100.0,
        height: 100.0,
      );
    }
    on SocketException catch(e){
      return Image.asset(
        "assets/images/logo.png",
        width: 100.0,
        height: 100.0,
      );
    }

0 个答案:

没有答案