'flutter direct share to whatsapp and telegram in android and ios

I want share a pdf file from flutter, directly to whatsapp and telegram in ios and android

Note 1: Flutter share_plus package can't do this, I want directly share to whatsapp and telegram without device native appchooser dialog for share.

Note 2: I don't want use universal links, because I can't sent file with this method, universal links only supports text.

Is there any package for this purpose? If there isn't, How can I write native code for this in ios and android?



Solution 1:[1]

Use this plugin to share all social media platforms socioal_share

Or if want to use this plugin for whatsapp, use the whatsapp_share: ^1.1.1 plugin

import 'package:whatsapp_share/whatsapp_share.dart';

For text

Future<void> share() async {
    await WhatsappShare.share(
      text: 'Whatsapp share text',
      linkUrl: 'https://flutter.dev/',
      phone: '911234567890',
    );
  }

For Files

Future<void> shareFile() async {
    await WhatsappShare.shareFile(
      text: 'Whatsapp share text',
      phone: '911234567890',
      filePath: [_image1.path, _image2.path],
    );
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anandh Krishnan