Flutter共享图像/文件(mimeType问题)

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

所以我需要与Flutter共享图像到另一个应用程序,我使用esys_flutter_share 1.0.2插件

Future<void> _shareImage(int index) async {
    final filename = _imageList[index].split("/")[2];
    try {
      final ByteData bytes = await rootBundle.load(_imageList[index]);
      await Share.file(
          'esys image', 'esys.png', bytes.buffer.asUint8List(), 'image/png',
          text: '$filename');
    } catch (e) {
      print('error: $e');
    }
  }

这是示例页面中的相同代码,将我的图像从我的应用程序共享到另一个应用程序,这是Android / Ios无法识别作为图像并共享为文本的mimeType的唯一问题(在Ios模拟器上甚至在真正的ios手机上)

Screenshot of the problemScreenshot how i need it

尝试过'image / png','image / jpg'等,总是像文本文件一样共享文件。

flutter dart mime-types
1个回答
0
投票

发现了我的问题,如果我让可选的字符串文本为空,则插件将共享文件为和图像文件,例如:

© www.soinside.com 2019 - 2024. All rights reserved.