shareMultipleFiles method

Future<void> shareMultipleFiles (
  1. Map<String, List<int>> filesBytes,
  2. String mimeType,
  3. {String shareTitle: 'Share with',
  4. String appToShare: '',
  5. String captionText: ''}
)

Implementation

static Future<void> shareMultipleFiles(
  Map<String, List<int>> filesBytes, //A list of file  byte format of the file see example on how to obtain
  String mimeType, // The type of text your sharing  ie text/txt image/png etc
  {
    String shareTitle = 'Share with', // The title that appears in the share pop up
    String appToShare = '', //The app you want to use to share with, if blank will pop up the share choose ie 'com.whatsapp'
    String captionText = '' //Caption text to share with.
  }) async {
  Map argsMap = <String, dynamic>{
    'shareTitle': '$shareTitle',
    'filesBytes': filesBytes.entries.toList().map((x) => x.key).toList(),
    'mimeType': mimeType,
    'captionText': '$captionText',
    'appToShare': '$appToShare'
  };

  final tempDir = await getTemporaryDirectory();

  for (var entry in filesBytes.entries) {
    final file = await new File('${tempDir.path}/${entry.key}').create();
    await file.writeAsBytes(entry.value);
  }
  _channel.invokeMethod('shareMultipleFiles', argsMap);
}