@@ -14,6 +14,8 @@ void main() {
1414}
1515
1616class MyApp extends StatelessWidget {
17+ final flutterWebviewPlugin = new FlutterWebviewPlugin ();
18+
1719 @override
1820 Widget build (BuildContext context) {
1921 return new MaterialApp (
@@ -37,6 +39,29 @@ class MyApp extends StatelessWidget {
3739 child: Text ('Waiting.....' ),
3840 ),
3941 ),
42+ bottomNavigationBar: BottomAppBar (
43+ child: Row (
44+ children: < Widget > [
45+ IconButton (
46+ icon: const Icon (Icons .arrow_back_ios),
47+ onPressed: () {
48+ flutterWebviewPlugin.goBack ();
49+ },
50+ ),
51+ IconButton (
52+ icon: const Icon (Icons .arrow_forward_ios),
53+ onPressed: () {
54+ flutterWebviewPlugin.goForward ();
55+ },
56+ ),
57+ IconButton (
58+ icon: const Icon (Icons .autorenew),
59+ onPressed: () {
60+ flutterWebviewPlugin.reload ();
61+ },
62+ ),
63+ ],
64+ )),
4065 )
4166 },
4267 );
@@ -168,77 +193,76 @@ class _MyHomePageState extends State<MyHomePage> {
168193 appBar: new AppBar (
169194 title: const Text ('Plugin example app' ),
170195 ),
171- body: new Column (
172- mainAxisAlignment: MainAxisAlignment .center,
173- children: [
174- new Container (
175- padding: const EdgeInsets .all (24.0 ),
176- child: new TextField (controller: _urlCtrl),
177- ),
178- new RaisedButton (
179- onPressed: () {
180- flutterWebviewPlugin.launch (selectedUrl,
181- rect: new Rect .fromLTWH (
182- 0.0 , 0.0 , MediaQuery .of (context).size.width, 300.0 ),
183- userAgent: kAndroidUserAgent);
184- },
185- child: const Text ('Open Webview (rect)' ),
186- ),
187- new RaisedButton (
188- onPressed: () {
189- flutterWebviewPlugin.launch (selectedUrl, hidden: true );
190- },
191- child: const Text ('Open "hidden" Webview' ),
192- ),
193- new RaisedButton (
194- onPressed: () {
195- flutterWebviewPlugin.launch (selectedUrl);
196- },
197- child: const Text ('Open Fullscreen Webview' ),
198- ),
199- new RaisedButton (
200- onPressed: () {
201- Navigator .of (context).pushNamed ('/widget' );
202- },
203- child: const Text ('Open widget webview' ),
204- ),
205- new Container (
206- padding: const EdgeInsets .all (24.0 ),
207- child: new TextField (controller: _codeCtrl),
208- ),
209- new RaisedButton (
210- onPressed: () {
211- final future =
212- flutterWebviewPlugin.evalJavascript (_codeCtrl.text);
213- future.then ((String result) {
214- setState (() {
215- _history.add ('eval: $result ' );
196+ body: SingleChildScrollView (
197+ child: new Column (
198+ mainAxisAlignment: MainAxisAlignment .center,
199+ children: [
200+ new Container (
201+ padding: const EdgeInsets .all (24.0 ),
202+ child: new TextField (controller: _urlCtrl),
203+ ),
204+ new RaisedButton (
205+ onPressed: () {
206+ flutterWebviewPlugin.launch (selectedUrl,
207+ rect: new Rect .fromLTWH (0.0 , 0.0 , MediaQuery .of (context).size.width, 300.0 ), userAgent: kAndroidUserAgent);
208+ },
209+ child: const Text ('Open Webview (rect)' ),
210+ ),
211+ new RaisedButton (
212+ onPressed: () {
213+ flutterWebviewPlugin.launch (selectedUrl, hidden: true );
214+ },
215+ child: const Text ('Open "hidden" Webview' ),
216+ ),
217+ new RaisedButton (
218+ onPressed: () {
219+ flutterWebviewPlugin.launch (selectedUrl);
220+ },
221+ child: const Text ('Open Fullscreen Webview' ),
222+ ),
223+ new RaisedButton (
224+ onPressed: () {
225+ Navigator .of (context).pushNamed ('/widget' );
226+ },
227+ child: const Text ('Open widget webview' ),
228+ ),
229+ new Container (
230+ padding: const EdgeInsets .all (24.0 ),
231+ child: new TextField (controller: _codeCtrl),
232+ ),
233+ new RaisedButton (
234+ onPressed: () {
235+ final future = flutterWebviewPlugin.evalJavascript (_codeCtrl.text);
236+ future.then ((String result) {
237+ setState (() {
238+ _history.add ('eval: $result ' );
239+ });
216240 });
217- });
218- },
219- child: const Text ('Eval some javascript' ),
220- ),
221- new RaisedButton (
222- onPressed: () {
223- setState (() {
224- _history.clear ();
225- });
226- flutterWebviewPlugin.close ();
227- },
228- child: const Text ('Close' ),
229- ),
230- new RaisedButton (
231- onPressed: () {
232- flutterWebviewPlugin.getCookies ().then ((m) {
241+ },
242+ child: const Text ('Eval some javascript' ),
243+ ),
244+ new RaisedButton (
245+ onPressed: () {
233246 setState (() {
234- _history.add ('cookies: $m ' );
247+ _history.clear ();
248+ });
249+ flutterWebviewPlugin.close ();
250+ },
251+ child: const Text ('Close' ),
252+ ),
253+ new RaisedButton (
254+ onPressed: () {
255+ flutterWebviewPlugin.getCookies ().then ((m) {
256+ setState (() {
257+ _history.add ('cookies: $m ' );
258+ });
235259 });
236- });
237- } ,
238- child : const Text ( 'Cookies' ),
239- ),
240- new Text (_history. join ( ' \n ' ))
241- ] ,
260+ },
261+ child : const Text ( 'Cookies' ) ,
262+ ),
263+ new Text (_history. join ( ' \n ' ))
264+ ],
265+ ) ,
242266 ),
243267 );
244268 }
0 commit comments