美文网首页
Image组件

Image组件

作者: 追风筝的Hassan | 来源:发表于2020-02-10 17:04 被阅读0次
     Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Welcome to Flutter',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: Scaffold(
            appBar: new AppBar(
              title: new Text('ListView Widget'),
            ),
            body: new ListView(
                children: <Widget>[new Image.asset('images/2.0x/ting.jpg')]),
          ),
        );
      }
    

    1.需要注意的是图片的资源需要放到images/2.0x或者iamges/3.0x文件下;
    2.在文件pubspec.yaml中加载图片资源,需要注意的是文件格式,以及对齐等eslint,否则会报错

    pubspec.yaml

    相关文章

      网友评论

          本文标题:Image组件

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