Commit 08b392e8 authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

updated docs, updated README.md

parent 3dd7d175
This diff is collapsed.
This diff is collapsed.
......@@ -14,8 +14,6 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
String url = "";
double progress = 0;
TextEditingController _textFieldController = TextEditingController();
@override
void initState() {
super.initState();
......@@ -24,93 +22,91 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
@override
void dispose() {
super.dispose();
_textFieldController.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"InAppWebView",
)),
title: Text("InAppWebView")
),
drawer: myDrawer(context: context),
body: Container(
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
child: Text(
"CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"),
),
Container(
padding: EdgeInsets.all(10.0),
child: progress < 1.0
? LinearProgressIndicator(value: progress)
: Container()),
Expanded(
child: Container(
margin: const EdgeInsets.all(10.0),
decoration:
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
initialUrl: "https://flutter.dev/",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
clearCache: true
)
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
setState(() {
this.url = url;
});
},
onLoadStop: (InAppWebViewController controller, String url) async {
setState(() {
this.url = url;
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
child: Text(
"CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"),
),
Container(
padding: EdgeInsets.all(10.0),
child: progress < 1.0
? LinearProgressIndicator(value: progress)
: Container()),
Expanded(
child: Container(
margin: const EdgeInsets.all(10.0),
decoration:
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
initialUrl: "https://flutter.dev/",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
)
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
setState(() {
this.url = url;
});
},
onLoadStop: (InAppWebViewController controller, String url) async {
setState(() {
this.url = url;
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
),
),
ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Icon(Icons.arrow_back),
onPressed: () {
if (webView != null) {
webView.goBack();
}
},
),
RaisedButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
if (webView != null) {
webView.goForward();
}
},
),
RaisedButton(
child: Icon(Icons.refresh),
onPressed: () {
if (webView != null) {
webView.reload();
}
},
),
],
),
])));
),
ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Icon(Icons.arrow_back),
onPressed: () {
if (webView != null) {
webView.goBack();
}
},
),
RaisedButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
if (webView != null) {
webView.goForward();
}
},
),
RaisedButton(
child: Icon(Icons.refresh),
onPressed: () {
if (webView != null) {
webView.reload();
}
},
),
],
),
]))
);
}
}
......@@ -42,7 +42,6 @@ flutter:
uses-material-design: true
assets:
- assets/certificate.pfx
- assets/index.html
- assets/page-1.html
- assets/page-2.html
......
......@@ -105,6 +105,7 @@ class ChromeSafariBrowser {
}
///Returns `true` if the [ChromeSafariBrowser] instance is opened, otherwise `false`.
bool isOpened() {
return this._isOpened;
}
......
......@@ -5,13 +5,14 @@ import 'package:flutter/services.dart';
import 'types.dart';
///Manages the cookies used by WebView instances.
///CookieManager class implements a singleton object (shared instance) which manages the cookies used by WebView instances.
///
///**NOTE for iOS**: available from iOS 11.0+.
class CookieManager {
static CookieManager _instance;
static const MethodChannel _channel = const MethodChannel('com.pichillilorenzo/flutter_inappbrowser_cookiemanager');
///Gets the cookie manager shared instance.
static CookieManager instance() {
return (_instance != null) ? _instance : _init();
}
......
......@@ -281,27 +281,32 @@ class InAppBrowser {
return this._isOpened;
}
///Event fires when the [InAppBrowser] is created.
///Event fired when the [InAppBrowser] is created.
void onBrowserCreated() {
}
///Event fires when the [InAppBrowser] starts to load an [url].
///Event fired when the [InAppBrowser] window is closed.
void onExit() {
}
///Event fired when the [InAppBrowser] starts to load an [url].
void onLoadStart(String url) {
}
///Event fires when the [InAppBrowser] finishes loading an [url].
///Event fired when the [InAppBrowser] finishes loading an [url].
void onLoadStop(String url) {
}
///Event fires when the [InAppBrowser] encounters an error loading an [url].
///Event fired when the [InAppBrowser] encounters an error loading an [url].
void onLoadError(String url, int code, String message) {
}
///Event fires when the [InAppBrowser] main page receives an HTTP error.
///Event fired when the [InAppBrowser] main page receives an HTTP error.
///
///[url] represents the url of the main page that received the HTTP error.
///
......@@ -314,17 +319,12 @@ class InAppBrowser {
}
///Event fires when the current [progress] (range 0-100) of loading a page is changed.
///Event fired when the current [progress] (range 0-100) of loading a page is changed.
void onProgressChanged(int progress) {
}
///Event fires when the [InAppBrowser] window is closed.
void onExit() {
}
///Event fires when the [InAppBrowser] webview receives a [ConsoleMessage].
///Event fired when the [InAppBrowser] webview receives a [ConsoleMessage].
void onConsoleMessage(ConsoleMessage consoleMessage) {
}
......@@ -336,14 +336,14 @@ class InAppBrowser {
}
///Event fires when the [InAppBrowser] webview loads a resource.
///Event fired when the [InAppBrowser] webview loads a resource.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnLoadResource] and [InAppWebViewOptions.javaScriptEnabled] options to `true`.
void onLoadResource(LoadedResource resource) {
}
///Event fires when the [InAppBrowser] webview scrolls.
///Event fired when the [InAppBrowser] webview scrolls.
///
///[x] represents the current horizontal scroll origin in pixels.
///
......@@ -352,7 +352,7 @@ class InAppBrowser {
}
///Event fires when [InAppBrowser] recognizes and starts a downloadable file.
///Event fired when [InAppBrowser] recognizes and starts a downloadable file.
///
///[url] represents the url of the file.
///
......@@ -361,7 +361,7 @@ class InAppBrowser {
}
///Event fires when the [InAppBrowser] webview finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
///Event fired when the [InAppBrowser] webview finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
///
///[scheme] represents the scheme of the url.
///
......@@ -371,7 +371,7 @@ class InAppBrowser {
}
///Event fires when the [InAppBrowser] webview tries to open a link with `target="_blank"`.
///Event fired when the [InAppBrowser] webview tries to open a link with `target="_blank"`.
///
///[url] represents the url of the link.
///
......@@ -386,13 +386,13 @@ class InAppBrowser {
///
///[origin] represents the origin of the web content attempting to use the Geolocation API.
///
///**NOTE**: available only for Android.
///**NOTE**: available only on Android.
// ignore: missing_return
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt (String origin) {
}
///Event fires when javascript calls the `alert()` method to display an alert dialog.
///Event fired when javascript calls the `alert()` method to display an alert dialog.
///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
......@@ -401,7 +401,7 @@ class InAppBrowser {
}
///Event fires when javascript calls the `confirm()` method to display a confirm dialog.
///Event fired when javascript calls the `confirm()` method to display a confirm dialog.
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
......@@ -410,7 +410,7 @@ class InAppBrowser {
}
///Event fires when javascript calls the `prompt()` method to display a prompt dialog.
///Event fired when javascript calls the `prompt()` method to display a prompt dialog.
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
......@@ -420,20 +420,20 @@ class InAppBrowser {
}
///Event fires when the webview notifies that a loading URL has been flagged by Safe Browsing.
///Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing.
///The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
///
///[url] represents the url of the request.
///
///[threatType] represents the reason the resource was caught by Safe Browsing, corresponding to a [SafeBrowsingThreat].
///
///**NOTE**: available only for Android.
///**NOTE**: available only on Android.
// ignore: missing_return
Future<SafeBrowsingResponse> onSafeBrowsingHit(String url, SafeBrowsingThreat threatType) {
}
///Event fires when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
///Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [HttpAuthChallenge].
// ignore: missing_return
......@@ -441,7 +441,7 @@ class InAppBrowser {
}
///Event fires when the WebView need to perform server trust authentication (certificate validation).
///Event fired when the WebView need to perform server trust authentication (certificate validation).
///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED].
///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge].
......@@ -506,7 +506,7 @@ class InAppBrowser {
}
///Event fired when an request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///It gives the host application a chance to take control over the request before sending it.
///
///[fetchRequest] represents a resource request.
......
This diff is collapsed.
......@@ -193,7 +193,7 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
///This class represents all the Android-only WebView options available.
class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions {
///Sets the text zoom of the page in percent. The default is `100`.
///Sets the text zoom of the page in percent. The default value is `100`.
int textZoom;
///Set to `true` to have the session cookie cache cleared before the new window is opened.
bool clearSessionCache;
......@@ -278,7 +278,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr
bool loadsImagesAutomatically;
///Sets the minimum logical font size. The default is `8`.
int minimumLogicalFontSize;
///Sets the initial scale for this WebView. 0 means default.The behavior for the default scale depends on the state of [useWideViewPort] and [loadWithOverviewMode].
///Sets the initial scale for this WebView. 0 means default. The behavior for the default scale depends on the state of [useWideViewPort] and [loadWithOverviewMode].
///If the content fits into the WebView control by width, then the zoom is set to 100%. For wide content, the behavior depends on the state of [loadWithOverviewMode].
///If its value is true, the content will be zoomed out to be fit by width into the WebView control, otherwise not.
///If initial scale is greater than 0, WebView starts with this value as initial scale.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment