-3

Can we make a WhatsApp video call on the click a button in flutter app ?

Rohan Thacker
  • 5,377
  • 3
  • 21
  • 34
Phanindra
  • 1,110
  • 2
  • 11
  • 24

2 Answers2

2

you can refer to WhatsApp official website and use universal link (see more). for example, you can send a sample text using this URL:

const url = "https://wa.me/<number>?text=SAMPLE TEXT";

if you try to open this URL and the user has WhatsApp in his/her phone, this message would open in this application. You can replace text with given keywords to start a phone call.

Abbasihsn
  • 2,075
  • 1
  • 7
  • 17
1

Add this Dependency then :

dependencies:
  call_with_whatsapp: ^0.0.1

Then :

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:call_with_whatsapp/call_with_whatsapp.dart';

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

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

class _MyAppState extends State<MyApp> {

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

  void _requestPermission() {
    CallWithWhatsapp.requestPermissions().then((x){
      print("success");
    }).catchError((e){
      print(e);
    });
  }

  void _openStore() {
    CallWithWhatsapp.openInPlayStore().then((x){
      print("success");
    }).catchError((e){
      print(e);
    });
  }

  void _initiateCall() {
    CallWithWhatsapp.initiateCall("01753230535").then((x){
      print("success");
    }).catchError((e){
      print(e);
    });
  }

  void _createNewContact() {
    CallWithWhatsapp.createContact("AAAAA AAAA", "0111111").then((x){
      print("success");
    }).catchError((e){
      print(e);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body:SafeArea(
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                RaisedButton(
                  onPressed: _requestPermission,
                  child: Text(
                    "Request permission",
                  ),
                ),
                RaisedButton(
                  onPressed: _openStore,
                  child: Text(
                    "Open In Playstore",
                  ),
                ),
                RaisedButton(
                  onPressed: _initiateCall,
                  child: Text(
                    "Initiate Call",
                  ),
                ),
                RaisedButton(
                  onPressed: _createNewContact,
                  child: Text(
                    "Create contact",
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }


}