【发布时间】:2020-07-29 15:55:18
【问题描述】:
我有一个分享按钮,它应该分享在轮播中显示的图像文件。 如何从显示的轮播中检索图像文件路径? 图像映射如下:
class ImgView extends StatelessWidget {
final List<Item> mItems;
final String title;
ImageView({this.mItems, @required this.title, Key key})
小部件主体的构建如下:
body: mItems.length == 1
? Center(child: Image.file(File(mItems[0].path)))
: Carousel(
images: mItems
.map((MediaItem item) => FileImage(File(item.path)))
.toList(growable: false),
),
);
} }
_sendEmail() async {
try {
//here I just hard coded the first image file path but i couldn't pass values which are currently displaying in Carousal
final ByteData bytes = await rootBundle.load(firstfileimagepath);
await Share.file(
'esys image', mediaItems[0].title+getFileExtensionFromPath(firstfileimagepath) , bytes.buffer.asUint8List(), 'image/png',
text: 'My optional text.');
} catch (e) {
throw 'Some message';
}
}
}
【问题讨论】:
-
您可以从地图中访问路径。有什么问题?
-
分享完整代码,不看完整代码就无法判断实际问题。
-
我已添加完整代码请看代码
-
我已经回答了你的问题,如果我遗漏了什么,请告诉我。
标签: flutter