以字符串形式存储图像

问题描述 投票:0回答:1

我已使用在线链接形式的图像。我想使用资产中的图像。有什么办法吗?

 child: _boxes(
              "https://nepaldrives.com/wp-content/uploads/2019/10/ktmnewservicecenter3.jpg",
              27.7147, 85.3355,"KTM Service Center"),
              Widget _boxes(String _image, double lat,double long,String restaurantName)

我已经以这种方式使用了该图像

 child: Image(
                          fit: BoxFit.fill,
                          image: NetworkImage(_image),
                        ),
flutter flutter-layout
1个回答
0
投票

正如您在评论中提到的,您要使用资产中的图像。因此,请替换您的

Image(
  image: NetworkImage(_image),
),

with

Image(
  image: AssetImage('assets/images/your_image.png'),
),
© www.soinside.com 2019 - 2024. All rights reserved.