flutter:导入图片到项目中并使用

一,创建目录并复制图片到目录下

如图:

二,编辑pubspec.yaml,把图片路径写入

三,代码中调用

      body: Center(
        child:Container(
          child: Image.asset(
            "images/b.png",
            repeat: ImageRepeat.noRepeat,
            fit: BoxFit.contain,
            color: Colors.transparent,
            colorBlendMode: BlendMode.colorDodge,
          ),
          width: Width,
          height: 300,
          color: Colors.black,
        ),
      ),

四,测试效果:

posted @ 2025-04-12 08:42  刘宏缔的架构森林  阅读(25)  评论(0)    收藏  举报