How to toggle the Tawk.to bot in flutter web?

188 Views Asked by At

I successfully integrated the Tawk.to chat bot in my flutter project by copying the script in my HTML body section.

I was wondering how I can toggle it in dart by clicking on a widget

I followed the documentation here https://help.tawk.to/article/using-a-text-link-or-button

in my flutter code I tried two methods

  1. Calling the link using url_launcher package

    Future<void> toggleBot() async {
    
    final url = Uri.parse("javascript:void(Tawk_API.toggle())");
    if (!await launchUrl(url)) {
      throw 'Could not launch $url';
    }}
    
  2. Using dart:js to call java script

    js.context.callMethod("window.Tawk_API.toggle()");
    

both of these methods do not work. what am I doing wrong? and how do I achieve what I am trying to achieve

0

There are 0 best solutions below