Php 如何在flatter中从web获取图片

Php 如何在flatter中从web获取图片,php,image,flutter,dart,barcode-scanner,Php,Image,Flutter,Dart,Barcode Scanner,我正在做扫描条码应用程序,我想扫描条码,并获得与信息的图片。首先,我成功地通过扫描条形码获得信息。在此之后,我想显示产品图片后,扫描条形码与他们的信息。所以我写了下面的代码,但我再次运行应用程序,然后抛出错误Nosuchmethoderror:null时调用了方法“/”,尝试调用:/(3)。那么,我应该怎么做才能同时传递图像和信息呢 @override Widget build(BuildContext context) { return Scaffold( backgr

我正在做扫描条码应用程序,我想扫描条码,并获得与信息的图片。首先,我成功地通过扫描条形码获得信息。在此之后,我想显示产品图片后,扫描条形码与他们的信息。所以我写了下面的代码,但我再次运行应用程序,然后抛出错误
Nosuchmethoderror:null时调用了方法“/”,尝试调用:/(3)
。那么,我应该怎么做才能同时传递图像和信息呢

@override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xFF121212),
      body: Center(
        child: product == null
            ? Text(
                  "Value : ${widget.code}",
                  style: TextStyle(color: Colors.blue),
              )
          : Container(
                child: Column(
                  children: <Widget>[
                    Container(
                    height: screenHeight / 3,
                        width: screenWidth / 1.5,
                        child: CachedNetworkImage(
                          fit: BoxFit.fill,
                          imageUrl:
                              "https://smileylion.com/easyshopping/productimage/${product.code}.jpg",
                          placeholder: (context, url) =>
                              new CircularProgressIndicator(),
                          errorWidget: (context, url, error) =>
                              new Icon(Icons.error),
                        ),
                    ),
                    
                    Text(
                      "CODE: ${product.code}",
                      style: TextStyle(fontSize: 20, color: Colors.white),
                    ),
@覆盖
小部件构建(构建上下文){
返回脚手架(
背景颜色:颜色(0xFF121212),
正文:中(
子项:product==null
?文本(
“值:${widget.code}”,
样式:TextStyle(颜色:Colors.blue),
)
:容器(
子:列(
儿童:[
容器(
高度:屏幕高度/3,
宽度:屏幕宽度/1.5,
子:CachedNetworkImage(
fit:BoxFit.fill,
图像URL:
"https://smileylion.com/easyshopping/productimage/${product.code}.jpg“,
占位符:(上下文,url)=>
新的CircularProgressIndicator(),
errorWidget:(上下文、url、错误)=>
新图标(Icons.error),
),
),
正文(
“代码:${product.CODE}”,
样式:TextStyle(字体大小:20,颜色:Colors.white),
),

我认为您的屏幕高度和屏幕宽度为空

你应该像这样分配它们

Widget build(BuildContext context) {
screenWidth =MediaQuery.of(context).size.width;
screenHeight=MediaQuery.of(context).size.height;
return ...

我希望这将是有益的

谢谢你,它对我很有用