From 6c97be3604c0f8e5423fc9000c2851f0bc1bc7fc Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Tue, 26 May 2020 00:44:14 +0200 Subject: [PATCH] fixed README.md HeadlessInAppWebView example --- README.md | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 14dc6338..cfa23b79 100755 --- a/README.md +++ b/README.md @@ -779,6 +779,7 @@ Example: ```dart import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; Future main() async { @@ -845,44 +846,43 @@ class _MyAppState extends State { return Scaffold( appBar: AppBar( title: Text( - "HeadlessInAppWebView", - )), - drawer: myDrawer(context: context), + "HeadlessInAppWebView", + )), body: SafeArea( - child: Column(children: [ - Container( - padding: EdgeInsets.all(20.0), - child: Text( - "CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"), - ), - Center( - child: RaisedButton( - onPressed: () async { - await headlessWebView.dispose(); - await headlessWebView.run(); - }, - child: Text("Run HeadlessInAppWebView")), - ), - Center( - child: RaisedButton( - onPressed: () async { - try { - await headlessWebView.webViewController.evaluateJavascript(source: """console.log('Here is the message!');"""); - } on MissingPluginException catch(e) { - print("HeadlessInAppWebView is not running. Click on \"Run HeadlessInAppWebView\"!"); - } - }, - child: Text("Send console.log message")), - ), - Center( - child: RaisedButton( - onPressed: () { - headlessWebView.dispose(); - }, - child: Text("Dispose HeadlessInAppWebView")), - ) - ]) - ) + child: Column(children: [ + Container( + padding: EdgeInsets.all(20.0), + child: Text( + "CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"), + ), + Center( + child: RaisedButton( + onPressed: () async { + await headlessWebView.dispose(); + await headlessWebView.run(); + }, + child: Text("Run HeadlessInAppWebView")), + ), + Center( + child: RaisedButton( + onPressed: () async { + try { + await headlessWebView.webViewController.evaluateJavascript(source: """console.log('Here is the message!');"""); + } on MissingPluginException catch(e) { + print("HeadlessInAppWebView is not running. Click on \"Run HeadlessInAppWebView\"!"); + } + }, + child: Text("Send console.log message")), + ), + Center( + child: RaisedButton( + onPressed: () { + headlessWebView.dispose(); + }, + child: Text("Dispose HeadlessInAppWebView")), + ) + ]) + ) ); } }