whatsapp_launcher 0.0.1 copy "whatsapp_launcher: ^0.0.1" to clipboard
whatsapp_launcher: ^0.0.1 copied to clipboard

Flutter package

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:whatsapp_launcher/whatsapp_launcher.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: WhatsAppDemo(),
    );
  }
}

class WhatsAppDemo extends StatelessWidget {
  final TextEditingController messageController = TextEditingController();

  WhatsAppDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("WhatsApp Launcher Example")),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: [
            TextField(
              controller: messageController,
              decoration: const InputDecoration(labelText: 'Message'),
            ),
            const SizedBox(height: 10),
            ElevatedButton(
              onPressed: () async {
                bool success = await WhatsAppLauncher.launchWhatsAppMessage(
                  phoneNumber: '919214529913', // Replace with test number
                  message: messageController.text,
                );
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: Text(success ? 'Launched!' : 'Failed to launch')),
                );
              },
              child: const Text("Send to WhatsApp"),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
150
points
30
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter package

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, url_launcher

More

Packages that depend on whatsapp_launcher