Skip to content

Send data from flutter to web app #306

@vinitk-aveosoft

Description

@vinitk-aveosoft

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions