Flutter 颤振\u交错\u网格\u视图中的图像未显示

Flutter 颤振\u交错\u网格\u视图中的图像未显示,flutter,Flutter,如此新的颤振,所以请原谅这个问题。我正在尝试使用图像,在Flatter交错网格视图的assets/image目录中。我将遵循本教程()。应用程序工作人员和我可以看到所有基于web URL的图片,但是,我的图片应该在一个空白的方框中。错误发生在myPhotoList('assets/images/food.jpg')中 同样,新的颤振,所以不确切地知道什么是图像标签需要在这里 谢谢你的帮助 公共规范yaml flutter: assets: - assets/images/ 代码 导入

如此新的颤振,所以请原谅这个问题。我正在尝试使用图像,在Flatter交错网格视图的assets/image目录中。我将遵循本教程()。应用程序工作人员和我可以看到所有基于web URL的图片,但是,我的图片应该在一个空白的方框中。错误发生在myPhotoList('assets/images/food.jpg')中

同样,新的颤振,所以不确切地知道什么是图像标签需要在这里

谢谢你的帮助

公共规范yaml

flutter:
  assets:
   - assets/images/
代码

导入“包装:颤振/材料.省道”;
导入“package:font_awesome_flatter/font_awesome_flatter.dart”;
导入“包:颤振交错网格视图/颤振交错网格视图.省道”;
类GridPage扩展了StatefulWidget{
@凌驾
_GridPageState createState()=>\u GridPageState();
}
类GridPageState扩展了状态{
@凌驾
小部件构建(构建上下文){
归还新脚手架(
appBar:appBar(
前导:图标按钮(图标:图标(Icons.menu,),ON按下:(){
//
}),
标题:文本(“加拿大制造的东西”),
),
主体:填充物(
填充:常数边集全部(8.0),
子:容器(
装饰:盒子装饰(
边界半径:边界半径。圆形(24.0),
颜色:颜色,白色,
),
子项:staggedGridView.count(
交叉轴计数:2,
主轴间距:4.0,
交叉轴间距:4.0,
交错文件:[
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
],
儿童:[
我的照片列表(
“assets/images/food.jpg”),
我的照片列表(
"https://images.unsplash.com/photo-1550496913-b1a19c3779e9?ixlib=rb-1.2.1&ixid=eyjhcbfawqiojeymdd9&auto=format&fit=crop&w=500&q=60“,
我的照片列表(
"https://images.unsplash.com/photo-1525344387229-da3782d11618?ixlib=rb-1.2.1&ixid=eyjhcbfawqiojeymdd9&auto=format&fit=crop&w=500&q=60“,
我的照片列表(
"https://images.unsplash.com/photo-1531496074234-6db4f0226092?ixlib=rb-1.2.1&ixid=eyjhcbfawqiojeymdd9&auto=format&fit=crop&w=500&q=60“,
我的照片列表(
"https://images.unsplash.com/photo-1522865080725-2a9ea1fcb94e?ixlib=rb-1.2.1&ixid=eyjhcbfawqiojeymdd9&auto=format&fit=crop&w=500&q=60“,
captionText(“挪威”,“刚刚”),
我的照片列表(
"https://images.unsplash.com/photo-1534546584494-57363237b97f?ixlib=rb-1.2.1&ixid=eyjhcbfawqiojeymdd9&auto=format&fit=crop&w=500&q=60“,
我的照片列表(
"https://images.unsplash.com/photo-1521320226546-87b106956014?ixlib=rb-1.2.1&auto=格式&fit=裁剪&w=500&q=60“,
我的照片列表(
"https://images.unsplash.com/photo-1486808044402-a7c67ef5ea7b?ixlib=rb-1.2.1&auto=格式&fit=裁剪&w=500&q=60“,
我的照片列表(
"https://images.unsplash.com/photo-1482076791374-bbc7876d9213?ixlib=rb-1.2.1&auto=格式&fit=裁剪&w=500&q=60“,
captionText(“山脉”,“2天前”),
],
填充:常数边集全部(4.0),
),
),
),
);
}
小部件标题文本(字符串标题文本、字符串子文本){
返回填充(
填充:常数边集全部(8.0),
子:容器(
子:列(
儿童:[
尺寸箱(高度:20.0),
对齐(
对齐:alignment.centerLeft,
子:容器(
子项:Text(titleText,
样式:TextStyle(颜色:Colors.black,fontSize:24.0),
),
),
对齐(
对齐:alignment.centerLeft,
子:容器(
子:文本(潜文本,
样式:TextStyle(颜色:Colors.blueGrey,fontSize:16.0),),
),
),
],
),
),
);
}
小部件myPhotoList(字符串MyImages){
返回容器(
装饰:盒子装饰(
图像:装饰图像(
fit:BoxFit.fill,
图片:NetworkImage(
MyImages),
),
),
);
}
}

在myPhotoList中,您可以像NetworkImage一样设置图像。您的内部映像将是AssetImage(path)

在myPhotoList中,您可以像NetworkImage一样设置图像。您的内部映像将是AssetImage(path)

myPhotoList小部件

Widget myPhotoList(String MyImages) {
    if(MyImages.contains("http")) {
      return Container(
        child: Image.network(MyImages),
      );
    }else{
      return Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            fit: BoxFit.fill,
            image: ExactAssetImage(
                MyImages),
          ),
        ),
      );
    }
  }

我的照片列表小部件

Widget myPhotoList(String MyImages) {
    if(MyImages.contains("http")) {
      return Container(
        child: Image.network(MyImages),
      );
    }else{
      return Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            fit: BoxFit.fill,
            image: ExactAssetImage(
                MyImages),
          ),
        ),
      );
    }
  }