whatsfile
This Flutter plugin for Android Platform to Share Pdf file to unsaved contacts in WhatsApp.
Features:
- This plugin is Share Pdf File to Specific Contact in WhatsApp.
- Plugin Supported for Unsaved Contacts.
- This Plugin Saved Contact to Mobile Phone.
Note:
- This Plugin Takes 8 to 10 Seconds To Share Pdf File To WhatsApp.
- Because Of Contact sync to Mobile it takes time.
- The Name Of the contact will be saved as My Contact.
Installation:
For Android:
If you pretends to use the file share, you need to configure the file provider, this will give access to the files turning possible to share with other applications
Add to AndroidManifest.xml
<application>
...
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true"
tools:ignore="MissingClass">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
Create xml Directory in res folder
- Inside the xml Directory create file
file_paths.xml
file.
Add res/xml/file_paths.xml
:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="files" path="/" />
<cache-path
name="cache"
path="/"/>
<external-path name="external_files" path="/" />
<external-cache-path
name="external_cache"
path="/" />
<external-files-path
name="external_files"
path="/" />
</paths>
How to use?
ElevatedButton(
onPressed: () async{
ShareToWhatsapp.sharePDF(paths!, 'application/pdf', "911234567890");
},
child: Text('Share PDF'),
),