iosWebViewFix/example/lib/main.dart

107 lines
2.6 KiB
Dart
Raw Normal View History

2018-09-14 00:21:51 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyInAppBrowser extends InAppBrowser {
@override
Future onLoadStart(String url) async {
2018-09-14 00:21:51 +00:00
print("\n\nStarted $url\n\n");
//print("\n\n ${await this.isHidden()} \n\n");
2018-09-14 00:21:51 +00:00
}
@override
Future onLoadStop(String url) async {
2018-09-14 00:21:51 +00:00
print("\n\nStopped $url\n\n");
// print(await this.injectScriptCode("document.body.innerHTML"));
// print(await this.injectScriptCode("3"));
// print(await this.injectScriptCode("""
// function asd (a,b) {
// return a+b;
// };
// asd(3,5);
// """));
// print(await this.injectScriptCode("""
// ["3",56,"sdf"];
// """));
// print(await this.injectScriptCode("""
// var x = {"as":4, "dfdfg": 6};
// x;
// """));
//print("\n\n ${await this.isHidden()} \n\n");
2018-09-23 23:53:22 +00:00
// await this.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js");
// this.injectScriptCode("""
// \$( "body" ).html( "Next Step..." )
// """);
//
// // add custom css
// this.injectStyleCode("""
// body {
// background-color: #3c3c3c !important;
// }
// """);
// this.injectStyleFile("https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css");
2018-09-14 00:21:51 +00:00
}
@override
void onLoadError(String url, int code, String message) {
2018-09-14 00:21:51 +00:00
print("\n\nCan't load $url.. Error: $message\n\n");
}
@override
void onExit() {
print("\n\nBrowser closed!\n\n");
}
2018-09-23 19:38:31 +00:00
@override
void shouldOverrideUrlLoading(String url) {
print("\n\n override $url\n\n");
this.loadUrl(url);
}
2018-09-14 00:21:51 +00:00
}
MyInAppBrowser inAppBrowser = new MyInAppBrowser();
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
2018-09-14 00:41:43 +00:00
title: const Text('Flutter InAppBrowser Plugin example app'),
2018-09-14 00:21:51 +00:00
),
body: new Center(
child: new RaisedButton(onPressed: () {
inAppBrowser.open("https://flutter.io/", options: {
"useChromeCustomTabs": true,
2018-09-23 19:38:31 +00:00
//"hidden": true,
//"toolbarTopFixedTitle": "Fixed title",
//"useShouldOverrideUrlLoading": true
//"hideUrlBar": true,
//"toolbarTop": false,
//"toolbarBottom": false
});
2018-09-14 00:21:51 +00:00
},
child: Text("Open InAppBrowser")
),
),
),
);
}
}