title: Flutter web: The communication between Flutter web and Flutter APP fails
body: <p><strong>APP</strong> : Developed with Flutter</p>
  <p><strong>Web</strong>: Develop with Flutter</p>
  <p>Use the <a href="https://pub.flutter-io.cn/packages/webview_flutter" rel="nofollow noreferrer">webview_flutter</a> plugin to load web pages in app.</p>
  <p>Now the web page wants to communicate with the APP.</p>
  <p>It is possible to use JavaScript methods to interact with flutter.</p>
  <p><strong>JavaScript code</strong></p>
  <pre><code>function toast() { 
      Toast.postMessage(&quot;message from web page&quot;);
  }
  </code></pre>
  <p><strong>Flutter APP code</strong></p>
  <pre><code>  JavascriptChannel _toasterJavascriptChannel(BuildContext context) {
      return JavascriptChannel(
          name: 'Toast',
          onMessageReceived: (JavascriptMessage message) {
            ScaffoldMessenger.of(context).showSnackBar(
              SnackBar(content: Text(message.message)),
            );
          });
    }
  </code></pre>
  <p>The above method is possible.</p>
  <p>But now Flutter web tries to interact with Flutter APP and <strong>fails</strong>, code show as below</p>
  <p><strong>Flutter web code</strong></p>
  <pre><code>  void toast() {
      html.window.postMessage(&quot;message from web page&quot;, &quot;Toast&quot;);
    }
  </code></pre>
  <p>Flutter APP code same as above.</p>
  <p>The error message is as follows</p>
  <blockquote>
  <p>I/chromium(25735): [INFO:CONSOLE(14560)] &quot;SyntaxError: Failed to
  execute 'postMessage' on 'Window': Invalid target origin 'Toast' in a
  call to 'postMessage'.&quot;</p>
  </blockquote>
  <p>Is there something wrong with my calling method?</p>