A Flutter plugin that provides a simple way to launch WhatsApp conversations with pre-filled messages using the official WhatsApp deep linking system. Supports both immediate and scheduled message sending.
whatsapp_launcher
A Flutter plugin to launch WhatsApp with a phone number and a pre-filled message using the wa.me deep link.
Features
- Open WhatsApp chat for a specific phone number
- Send pre-filled messages
- Schedule messages for future delivery
- Simple and easy-to-use API
- Supports both Android and iOS platforms
- Handles error cases gracefully
Getting Started
Add the dependency in your pubspec.yaml
:
dependencies:
whatsapp_launcher: ^1.0.0
Usage
Here's a simple example of how to use the plugin:
import 'package:whatsapp_launcher/whatsapp_launcher.dart';
// Send message immediately
void sendMessage() async {
bool launched = await WhatsAppLauncher.launchWhatsAppMessage(
phoneNumber: '919999999999', // Use international format without '+'
message: 'Hello from Flutter!',
);
if (!launched) {
print('Could not open WhatsApp');
}
}
// Schedule a message
void scheduleMessage() async {
bool scheduled = await WhatsAppLauncher.scheduleWhatsAppMessage(
phoneNumber: '919999999999',
message: 'This is a scheduled message!',
scheduledTime: DateTime.now().add(Duration(hours: 2)), // Schedule for 2 hours later
);
if (!scheduled) {
print('Could not schedule WhatsApp message');
}
}
Parameters
phoneNumber
: The recipient's phone number in international format without the '+' symbol (e.g., '919999999999')message
: The pre-filled message to be sent (optional)scheduledTime
: The DateTime when the message should be sent (for scheduled messages)
Requirements
- WhatsApp must be installed on the user's device
- Supported on both Android and iOS platforms
- For Android: Requires minimum SDK version 16
- For iOS: Requires iOS 9.0 or later
Additional Information
For more detailed examples and implementation details, check out the /example
directory in the package repository.