title: Flutter - How to get a Javascript callback in WebView?
body: <p>I am using a <code>WebView</code> to load a local HTML file that contains the callback -</p>
  <pre><code>function onReward(data){
  console.log(&quot;onReward: &quot; + data.earnedThisSession);
  Survey.postMessage(data.earnedThisSession);
  }
  </code></pre>
  <p>This callback gets triggered when a user completes an action, I am currently facing two problems</p>
  <ol>
  <li>The <code>data.earnedThisSession</code> returned by the function differs from every user and I want to get this as a variable in my dart code to reward my user</li>
  <li>My <code>WebView</code> dependency is not printing console messages in my debug console</li>
  </ol>
  <p>This is my <code>JavascriptChannel</code> -</p>
  <pre><code>final Set&lt;JavascriptChannel&gt; jsChannels = [
    JavascriptChannel(
        name: 'Survey',
        onMessageReceived: (JavascriptMessage message) {
          print(message.message);
        }),
  ].toSet();
  </code></pre>
  <p>This is my <code>WebviewScaffold</code> -</p>
  <pre><code>FutureBuilder&lt;String&gt;(
                future: _loadLocalHTML(),
                builder: (context, snapshot) {
                  if (snapshot.hasData) {
                    return Scaffold(
                      appBar: AppBar(),
                      body: WebView(
                        initialUrl: Uri.dataFromString(
                          snapshot.data,
                          mimeType: 'text/html',
                          encoding: Encoding.getByName('utf-8'),
                        ).toString(),
                        javascriptChannels: jsChannels,
                        javascriptMode: JavascriptMode.unrestricted,
                      ),
                    );
                  }
  </code></pre>
  <p>How do I use <code>evalJavascript</code> in this to fetch my reward data?</p>