import 'dart:async';

import 'package:flutter/services.dart';

class WhatsappMethodChannel {
  static const MethodChannel _channel = MethodChannel('whats_app_otp');

  FutureOr<void> handleHandShake() async {
    try {
      await _channel.invokeMethod("performHandShake");

    } on PlatformException catch (e) {
      print("Failed to launch PenguinIn: '${e.message}'.");
    }
  }

  Future<bool> isWhatsAppInstalled() async {
    try {
      return await _channel.invokeMethod("isWhatsAppInstalled");
    } catch (e) {
      return false;
    }
  }

  Future<String> startListening() async {
    try{
      String code =  await _channel.invokeMethod("startListening");
      print("the code in flutter is ${code}");
      return code;
    }catch(e){
      return "";
    }
  }
}