flutter-webview-windows icon indicating copy to clipboard operation
flutter-webview-windows copied to clipboard

Send data from flutter to web app

Open vinitk-aveosoft opened this issue 6 months ago • 0 comments

Hey forks, I am working on a app which needs a Rich text editor. I have designed editor using React and self hosted the build HTML, CSS, JS with "shelf" and "shelf_flutter_asset" and viewing it with WebView.

Operation 1: Sending onChange data from Web App Editor to Flutter and saving it on DB (Successful) I used below code Editor end: ((e) => { console.log("debouncedEditorData: ", e); window.chrome.webview.postMessage(e); })

Flutter end:
`webViewController.webMessage.listen(
    (event) async {
      kprint(
          title: 'webview', object: 'On Message from Window Webview : $event');
    },
  );`
  

Operation 2: I want to send data from flutter to editor so I can prefill it when the editor is loaded for the first time (Need help here) I tried with triggering a demo function like below kprint( title: 'WebView', object: await webViewController .executeScript('triggerCustomEvent();')); Problem I am facing is that I was able to add a new function above the main function. The main function is too huge after being compiled and I have no clue how to trigger the prefilling function. Is there any other way to tackle this using some kind of anchor or any alternate approach.

vinitk-aveosoft avatar Aug 08 '24 10:08 vinitk-aveosoft