搜索插件、代码仓与 APP 分类

插件详情v2.0.2

whatsapp_share

在您的 Flutter 应用中,通过 WhatsApp 与特定联系人分享消息、链接或文件的简单方法。

Android
近 30 天下载
131
喜欢数
40
Pub 分数
160

安装插件

flutter pub add whatsapp_share

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个轻量级的 Flutter 包,可在 Android 上通过 WhatsApp 直接将消息、链接或文件分享给特定联系人。它简化了打开 WhatsApp 并预填充内容和目标联系人号码的过程,通过无缝通信提升用户参与度。该包利用 Android 意图实现原生集成,确保可靠传递且设置简单。非常适合希望借助直接消息功能提升用户触达的应用。

适合场景

  • 分享推荐链接
  • 发送支持消息
  • 分发促销内容
  • 引导用户联系客服
  • 自动化跟进消息
  • 共享媒体文件

主要特点

  • 与 Android 意图的轻松集成
  • 支持文本、链接和文件
  • 针对特定的 WhatsApp 联系人
  • 最小配置要求
  • 依赖原生 WhatsApp 功能
  • 初始设置后可离线使用

适合对象

  • 需要直接访问 WhatsApp 联系人的应用
  • 客户支持功能
  • 营销和推荐系统
  • 内容分发工具
  • 用户入门流程

使用建议

  • 仅限 Android 平台支持
  • 需要在设备上安装 WhatsApp
  • 仅限联系人共享
  • 无 iOS 兼容性
  • 依赖系统级权限
  • 可能需要用户确认才能共享

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Whatsapp Share Plugin

pub package

A Flutter plugin for Android providing a simple way to share a message, link or local files to specific WhatsApp contact.

Features:

  • Share messages or link urls to specific contact.
  • Share local files to specific contact.

Installation

First, add this to your package's pubspec.yaml file:

dependencies:
  whatsapp_share: ^1.1.1

Now in your Dart code, you can use:

import 'package:whatsapp_share/whatsapp_share.dart';

Installation (Platform Specific)

iOS

Add if not exists one row to the ios/podfile after target runner:

...

target 'Runner' do
    use_frameworks!

...
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">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
</provider>
</application>

Obs: You can change the android:name if you have an extension of file provider.

Add res/xml/provider_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

If you want to learn more about file provider you can access:

  • https://developer.android.com/reference/android/support/v4/content/FileProvider

How to use?

Here is an snippets app displaying the two whatsapp share methods .

Whatsapp installed in this device ?
 Future<void> isInstalled() async {
    final val = await WhatsappShare.isInstalled(
      package: Package.businessWhatsapp
    );
    print('Whatsapp Business is installed: $val');
  }

If whatsapp is not installed, please do not call WhatsappShare.share() and WhatsappShare.shareFile()

Share text, links

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

Share images, files

_image1.path contains path of the file which is shared to the whatsapp.


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

所属分类

源码仓库

使用此插件的项目

暂无相关数据。