@@ -16,11 +16,17 @@ For help on editing plugin code, view the [documentation](https://flutter.io/dev
First, add `flutter_inappbrowser` as a [dependency in your pubspec.yaml file](https://flutter.io/using-packages/).
## Usage
Classes:
-[InAppBrowser](#inappbrowser): Native WebView.
-[ChromeSafariBrowser](#chromesafaribrowser): [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android / [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS.
Screenshots [here](#screenshots).
### `InAppBrowser` class
Create a Class that extends the `InAppBrowser` Class in order to override the callbacks to manage the browser events.
Injects JavaScript code into the `InAppBrowser` window and returns the result of the evaluation. (Only available when the target is set to `_blank` or to `_self`)
...
...
@@ -319,7 +325,7 @@ Injects JavaScript code into the `InAppBrowser` window and returns the result of
inAppBrowser.injectScriptCode(Stringsource);
```
### Future\<void\> InAppBrowser.injectScriptFile
#### Future\<void\> InAppBrowser.injectScriptFile
Injects a JavaScript file into the `InAppBrowser` window. (Only available when the target is set to `_blank` or to `_self`)
...
...
@@ -327,7 +333,7 @@ Injects a JavaScript file into the `InAppBrowser` window. (Only available when t
inAppBrowser.injectScriptFile(StringurlFile);
```
### Future\<void\> InAppBrowser.injectStyleCode
#### Future\<void\> InAppBrowser.injectStyleCode
Injects CSS into the `InAppBrowser` window. (Only available when the target is set to `_blank` or to `_self`)
...
...
@@ -335,7 +341,7 @@ Injects CSS into the `InAppBrowser` window. (Only available when the target is s
inAppBrowser.injectStyleCode(Stringsource);
```
### Future\<void\> InAppBrowser.injectStyleFile
#### Future\<void\> InAppBrowser.injectStyleFile
Injects a CSS file into the `InAppBrowser` window. (Only available when the target is set to `_blank` or to `_self`)
...
...
@@ -343,8 +349,173 @@ Injects a CSS file into the `InAppBrowser` window. (Only available when the targ
inAppBrowser.injectStyleFile(StringurlFile);
```
### `ChromeSafariBrowser` class
Create a Class that extends the `ChromeSafariBrowser` Class in order to override the callbacks to manage the browser events. Example:
Opens an `url` in a new `ChromeSafariBrowser` instance or the system browser.
-`url`: The `url` to load. Call `encodeUriComponent()` on this if the `url` contains Unicode characters.
-`options`: Options for the `ChromeSafariBrowser`.
-`headersFallback`: The additional header of the `InAppBrowser` instance fallback to be used in the HTTP request for this URL, specified as a map from name to value.
-`optionsFallback`: Options used by the `InAppBrowser` instance fallback.
**Android** supports these options:
- __addShareButton__: Set to `false` if you don't want the default share button. The default value is `true`.
- __showTitle__: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
- __toolbarBackgroundColor__: Set the custom background color of the toolbar.
- __enableUrlBarHiding__: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
- __instantAppsEnabled__: Set to `true` to enable Instant Apps. The default value is `false`.
**iOS** supports these options:
- __entersReaderIfAvailable__: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
- __barCollapsingEnabled__: Set to `true` to enable bar collapsing. The default value is `false`.
- __dismissButtonStyle__: Set the custom style for the dismiss button. The default value is `0 //done`. See [SFSafariViewController.DismissButtonStyle](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/dismissbuttonstyle) for all the available styles.
- __preferredBarTintColor__: Set the custom background color of the navigation bar and the toolbar.
- __preferredControlTintColor__: Set the custom color of the control buttons on the navigation bar and the toolbar.
- __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
- __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
///Initialize the [ChromeSafariBrowser] instance with a [InAppBrowser] fallback instance or `null`.
ChromeSafariBrowser(bf){
uuid=uuidGenerator.v4();
browserFallback=bf;
...
...
@@ -325,7 +325,33 @@ class ChromeSafariBrowser {
returnnewFuture.value("");
}
///Opens an [url] in a new [ChromeSafariBrowser] instance or the system browser.
///
///- [url]: The [url] to load. Call [encodeUriComponent()] on this if the [url] contains Unicode characters.
///
///- [options]: Options for the [ChromeSafariBrowser].
///
///- [headersFallback]: The additional header of the [InAppBrowser] instance fallback to be used in the HTTP request for this URL, specified as a map from name to value.
///
///- [optionsFallback]: Options used by the [InAppBrowser] instance fallback.
///
///**Android** supports these options:
///
///- __addShareButton__: Set to `false` if you don't want the default share button. The default value is `true`.
///- __showTitle__: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
///- __toolbarBackgroundColor__: Set the custom background color of the toolbar.
///- __enableUrlBarHiding__: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
///- __instantAppsEnabled__: Set to `true` to enable Instant Apps. The default value is `false`.
///
///**iOS** supports these options:
///
///- __entersReaderIfAvailable__: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
///- __barCollapsingEnabled__: Set to `true` to enable bar collapsing. The default value is `false`.
///- __dismissButtonStyle__: Set the custom style for the dismiss button. The default value is `0 //done`. See [SFSafariViewController.DismissButtonStyle](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/dismissbuttonstyle) for all the available styles.
///- __preferredBarTintColor__: Set the custom background color of the navigation bar and the toolbar.
///- __preferredControlTintColor__: Set the custom color of the control buttons on the navigation bar and the toolbar.
///- __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
///- __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.