美文网首页
😂【Flutter】无法加载资源图片问题!

😂【Flutter】无法加载资源图片问题!

作者: zoustin | 来源:发表于2019-04-11 23:26 被阅读0次
    image
    😟问题阐述:怎么也无法加载,我是一脸懵逼,后面试了以下加入assest/就行了,我靠~
    image
        //AssetImage assetImage = new AssetImage('images/abc.jpg'); 出问题
        //加入assets就没问题
        AssetImage assetImage = new AssetImage('assets/images/abc.jpg');
        return new MaterialApp(
          title: "如何构建一个布局",
          theme: new ThemeData(
            primarySwatch: Colors.blue
          ),
          home: Scaffold(
            appBar: AppBar(title: Text("Fultter layout demo"),),
            body: ListView(
              children: <Widget>[
            new Image(image: assetImage,width: 600,height: 240.0,fit: BoxFit.cover,),
              titleSection,
              buttonSection,
              textSection,
            ],),
          ),
        );
    
    📣另外一点也要注意: - assets前面的缩减空格 ,可以会使Packages get获取不成功!!格式要规范正确
    flutter:
     # The following line ensures that the Material Icons font is
     # included with your application, so that you can use the icons in
     # the material Icons class.
     uses-material-design: true
     # To add assets to your application, add an assets section, like this:
     assets:
     - assets/images/abc.jpg
     - assets/images/abcc.png
    
    📣不正确的缩进,例如👇
    5caf56ee64fb3
    📣结果就成这样了!😱
    5caf56e3ccaff

    相关文章

      网友评论

          本文标题:😂【Flutter】无法加载资源图片问题!

          本文链接:https://www.haomeiwen.com/subject/klmfwqtx.html