/flutter_launch_whatsapp

Plugin flutter to launch whatsapp

Primary LanguageKotlinGNU General Public License v3.0GPL-3.0

flutter_launch

pub package

A Flutter plugin for launching a whatsApp. Supports: iOS, Android

Usage

To use this plugin, add flutter_launch_whatsapp as a dependency in your pubspec.yaml file.

Installation

iOS

Add the following entry to your Info.plist file, located in /ios/Runner/Info.plist:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>whatsapp, tg</string>
</array>

Android

n/a

Example

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

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  initState() {
    super.initState();
  }

  void whatsAppOpen() async {
    await FlutterLaunch.launchWathsApp(phone: "5534992016545", message: "Hello");
  }

  void telegramAppOpen() async {
    await FlutterLaunch.launchTelegram(domain: "5534992016545");
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: Center(
           child: Column(
               mainAxisAlignment: MainAxisAlignment.center,
               children: [
                 TextButton(
                   child: Text("Open WhatsApp"),
                   onPressed: () {
                     whatsAppOpen();
                   },
                 ),
                 TextButton(
                   child: Text("Open Telegram"),
                   onPressed: () {
                     telegramAppOpen();
                   },
                 )
               ]
           )
       );
      ),
    );
  }
}