Commit ec348cd8 authored by pichillilorenzo's avatar pichillilorenzo

v0.5.2

parent 867715ea
This diff is collapsed.
## 0.5.2
- fixed some missing `result.success()` on Android and iOS
- added `postUrl()` method for `InAppWebView` and `InAppBrowser`
- added `loadData()` method for `InAppWebView` and `InAppBrowser`
## 0.5.1 ## 0.5.1
- updated README.md - updated README.md
......
...@@ -295,7 +295,6 @@ InAppWebView( ...@@ -295,7 +295,6 @@ InAppWebView(
} }
``` ```
#### Future\<void\> InAppWebViewController.loadUrl #### Future\<void\> InAppWebViewController.loadUrl
Loads the given `url` with optional `headers` specified as a map from name to value. Loads the given `url` with optional `headers` specified as a map from name to value.
...@@ -304,6 +303,24 @@ Loads the given `url` with optional `headers` specified as a map from name to va ...@@ -304,6 +303,24 @@ Loads the given `url` with optional `headers` specified as a map from name to va
inAppWebViewController.loadUrl(String url, {Map<String, String> headers = const {}}); inAppWebViewController.loadUrl(String url, {Map<String, String> headers = const {}});
``` ```
#### Future\<void\> InAppWebViewController.postUrl
Loads the given `url` with `postData` using `POST` method into this WebView.
```dart
inAppWebViewController.postUrl(String url, Uint8List postData);
```
#### Future\<void\> InAppWebViewController.loadData
Loads the given `data` into this WebView, using `baseUrl` as the base URL for the content.
The `mimeType` parameter specifies the format of the data.
The `encoding` parameter specifies the encoding of the data.
```dart
inAppWebViewController.loadData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank"});
```
#### Future\<void\> InAppWebViewController.loadFile #### Future\<void\> InAppWebViewController.loadFile
Loads the given `assetFilePath` with optional `headers` specified as a map from name to value. Loads the given `assetFilePath` with optional `headers` specified as a map from name to value.
......
...@@ -83,6 +83,25 @@ public class FlutterWebView implements PlatformView, MethodCallHandler { ...@@ -83,6 +83,25 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
else else
result.success(false); result.success(false);
break; break;
case "postUrl":
if (webView != null)
webView.postUrl(call.argument("url").toString(), (byte[]) call.argument("postData"), result);
else
result.success(false);
break;
case "loadData":
{
String data = call.argument("data").toString();
String mimeType = call.argument("mimeType").toString();
String encoding = call.argument("encoding").toString();
String baseUrl = call.argument("baseUrl").toString();
if (webView != null)
webView.loadData(data, mimeType, encoding, baseUrl, result);
else
result.success(false);
}
break;
case "loadFile": case "loadFile":
if (webView != null) if (webView != null)
webView.loadFile(call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result); webView.loadFile(call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result);
......
...@@ -180,6 +180,22 @@ public class InAppBrowserActivity extends AppCompatActivity { ...@@ -180,6 +180,22 @@ public class InAppBrowserActivity extends AppCompatActivity {
} }
} }
public void postUrl(String url, byte[] postData, MethodChannel.Result result) {
if (webView != null) {
webView.postUrl(url, postData, result);
} else {
result.error(LOG_TAG, "Cannot load url " + url, null);
}
}
public void loadData(String data, String mimeType, String encoding, String baseUrl, MethodChannel.Result result) {
if (webView != null) {
webView.loadData(data, mimeType, encoding, baseUrl, result);
} else {
result.error(LOG_TAG, "Cannot load data", null);
}
}
public void loadFile(String url, MethodChannel.Result result) { public void loadFile(String url, MethodChannel.Result result) {
if (webView != null) { if (webView != null) {
webView.loadFile(url, result); webView.loadFile(url, result);
......
...@@ -137,8 +137,7 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler { ...@@ -137,8 +137,7 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
if (openWithSystemBrowser) { if (openWithSystemBrowser) {
Log.d(LOG_TAG, "in system"); Log.d(LOG_TAG, "in system");
openExternal(url, result); openExternal(url, result);
} } else {
else {
//Load the dialer //Load the dialer
if (url.startsWith(WebView.SCHEME_TEL)) { if (url.startsWith(WebView.SCHEME_TEL)) {
try { try {
...@@ -163,6 +162,18 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler { ...@@ -163,6 +162,18 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
case "loadUrl": case "loadUrl":
loadUrl(uuid, call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result); loadUrl(uuid, call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result);
break; break;
case "postUrl":
postUrl(uuid, call.argument("url").toString(), (byte[]) call.argument("postData"), result);
break;
case "loadData":
{
String data = call.argument("data").toString();
String mimeType = call.argument("mimeType").toString();
String encoding = call.argument("encoding").toString();
String baseUrl = call.argument("baseUrl").toString();
loadData(uuid, data, mimeType, encoding, baseUrl, result);
}
break;
case "loadFile": case "loadFile":
loadFile(uuid, call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result); loadFile(uuid, call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result);
break; break;
...@@ -393,6 +404,18 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler { ...@@ -393,6 +404,18 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
} }
} }
public void postUrl(String uuid, String url, byte[] postData, Result result) {
InAppBrowserActivity inAppBrowserActivity = webViewActivities.get(uuid);
if (inAppBrowserActivity != null)
inAppBrowserActivity.postUrl(url, postData, result);
}
public void loadData(String uuid, String data, String mimeType, String encoding, String baseUrl, Result result) {
InAppBrowserActivity inAppBrowserActivity = webViewActivities.get(uuid);
if (inAppBrowserActivity != null)
inAppBrowserActivity.loadData(data, mimeType, encoding, baseUrl, result);
}
public void loadFile(String uuid, String url, Map<String, String> headers, Result result) { public void loadFile(String uuid, String url, Map<String, String> headers, Result result) {
InAppBrowserActivity inAppBrowserActivity = webViewActivities.get(uuid); InAppBrowserActivity inAppBrowserActivity = webViewActivities.get(uuid);
if (inAppBrowserActivity != null) { if (inAppBrowserActivity != null) {
......
...@@ -183,7 +183,9 @@ public class InAppWebView extends WebView { ...@@ -183,7 +183,9 @@ public class InAppWebView extends WebView {
loadUrl(url); loadUrl(url);
} else { } else {
result.error(LOG_TAG, "url is empty", null); result.error(LOG_TAG, "url is empty", null);
return;
} }
result.success(true);
} }
public void loadUrl(String url, Map<String, String> headers, MethodChannel.Result result) { public void loadUrl(String url, Map<String, String> headers, MethodChannel.Result result) {
...@@ -191,7 +193,24 @@ public class InAppWebView extends WebView { ...@@ -191,7 +193,24 @@ public class InAppWebView extends WebView {
loadUrl(url, headers); loadUrl(url, headers);
} else { } else {
result.error(LOG_TAG, "url is empty", null); result.error(LOG_TAG, "url is empty", null);
return;
} }
result.success(true);
}
public void postUrl(String url, byte[] postData, MethodChannel.Result result) {
if (!url.isEmpty()) {
postUrl(url, postData);
} else {
result.error(LOG_TAG, "url is empty", null);
return;
}
result.success(true);
}
public void loadData(String data, String mimeType, String encoding, String baseUrl, MethodChannel.Result result) {
loadDataWithBaseURL(baseUrl, data, mimeType, encoding, null);
result.success(true);
} }
public void loadFile(String url, MethodChannel.Result result) { public void loadFile(String url, MethodChannel.Result result) {
...@@ -206,7 +225,9 @@ public class InAppWebView extends WebView { ...@@ -206,7 +225,9 @@ public class InAppWebView extends WebView {
loadUrl(url); loadUrl(url);
} else { } else {
result.error(LOG_TAG, "url is empty", null); result.error(LOG_TAG, "url is empty", null);
return;
} }
result.success(true);
} }
public void loadFile(String url, Map<String, String> headers, MethodChannel.Result result) { public void loadFile(String url, Map<String, String> headers, MethodChannel.Result result) {
...@@ -221,7 +242,9 @@ public class InAppWebView extends WebView { ...@@ -221,7 +242,9 @@ public class InAppWebView extends WebView {
loadUrl(url, headers); loadUrl(url, headers);
} else { } else {
result.error(LOG_TAG, "url is empty", null); result.error(LOG_TAG, "url is empty", null);
return;
} }
result.success(true);
} }
public boolean isLoading() { public boolean isLoading() {
......
import 'dart:async'; import 'dart:async';
import 'dart:convert' show base64; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
...@@ -7,9 +7,9 @@ class MyInAppBrowser extends InAppBrowser { ...@@ -7,9 +7,9 @@ class MyInAppBrowser extends InAppBrowser {
@override @override
Future onLoadStart(String url) async { Future onLoadStart(String url) async {
print("\n\nStarted $url\n\n"); print("\n\nStarted $url\n\n");
print("\n\n ${await this.isHidden()} \n\n"); // print("\n\n ${await this.isHidden()} \n\n");
print(await this.webViewController.canGoBack()); // print(await this.webViewController.canGoBack());
print(await this.webViewController.canGoForward()); // print(await this.webViewController.canGoForward());
} }
@override @override
...@@ -105,7 +105,7 @@ class MyInAppBrowser extends InAppBrowser { ...@@ -105,7 +105,7 @@ class MyInAppBrowser extends InAppBrowser {
@override @override
void onProgressChanged(int progress) { void onProgressChanged(int progress) {
print("Progress: $progress"); // print("Progress: $progress");
} }
@override @override
...@@ -117,6 +117,47 @@ class MyInAppBrowser extends InAppBrowser { ...@@ -117,6 +117,47 @@ class MyInAppBrowser extends InAppBrowser {
void shouldOverrideUrlLoading(String url) { void shouldOverrideUrlLoading(String url) {
print("\n\n override $url\n\n"); print("\n\n override $url\n\n");
this.webViewController.loadUrl(url); this.webViewController.loadUrl(url);
// var postData = "username=my_username&password=my_password";
// inAppBrowserFallback.webViewController.postUrl("http://localhost:8080", utf8.encode(postData));
// var htmlData = """
//<!doctype html>
//<html lang="en">
//<head>
// <meta charset="UTF-8">
// <meta name="viewport"
// content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
// <meta http-equiv="X-UA-Compatible" content="ie=edge">
// <title>Document</title>
// <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
// <link rel="stylesheet" href="http://localhost:8080/assets/css/style.css">
// <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
//</head>
//<body>
//<div class="container">
// <div class="container">
// <img src="http://localhost:8080/assets/images/dart.svg" alt="dart logo">
// <div class="row">
// <div class="col-sm">
// One of three columns
// </div>
// <div class="col-sm">
// One of three columns
// </div>
// <div class="col-sm">
// One of three columns
// </div>
// </div>
// </div>
// <script>
// console.log("hello");
// </script>
//</div>
//</body>
//</html>
// """;
// inAppBrowserFallback.webViewController.loadData(htmlData);
} }
@override @override
...@@ -231,10 +272,10 @@ class _MyAppState extends State<MyApp> { ...@@ -231,10 +272,10 @@ class _MyAppState extends State<MyApp> {
// }); // });
// //
await inAppBrowserFallback.open(url: "https://flutter.io/", options: { await inAppBrowserFallback.open(url: "https://flutter.io/", options: {
"useOnLoadResource": true, //"useOnLoadResource": true,
//"hidden": true, //"hidden": true,
//"toolbarTopFixedTitle": "Fixed title", //"toolbarTopFixedTitle": "Fixed title",
//"useShouldOverrideUrlLoading": true "useShouldOverrideUrlLoading": true
//"hideUrlBar": true, //"hideUrlBar": true,
//"toolbarTop": false, //"toolbarTop": false,
//"toolbarBottom": false //"toolbarBottom": false
......
...@@ -378,6 +378,34 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -378,6 +378,34 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
webView.load(request) webView.load(request)
} }
func loadData(data: String, mimeType: String, encoding: String, baseUrl: String) {
let url = URL(string: baseUrl)!
currentURL = url
if #available(iOS 9.0, *) {
webView.load(data.data(using: .utf8)!, mimeType: mimeType, characterEncodingName: encoding, baseURL: url)
} else {
webView.loadHTMLString(data, baseURL: url)
}
}
func postUrl(url: URL, postData: Data, result: @escaping FlutterResult) {
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { (data : Data?, response : URLResponse?, error : Error?) in
var returnString = ""
if data != nil {
returnString = String(data: data!, encoding: .utf8) ?? ""
}
DispatchQueue.main.async(execute: {() -> Void in
self.webView.loadHTMLString(returnString, baseURL: url)
result(true)
})
}
task.resume()
}
// Load user requested url // Load user requested url
func textFieldShouldReturn(_ textField: UITextField) -> Bool { func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder() textField.resignFirstResponder()
......
...@@ -68,6 +68,12 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin { ...@@ -68,6 +68,12 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
case "loadUrl": case "loadUrl":
self.loadUrl(uuid: uuid, arguments: arguments!, result: result) self.loadUrl(uuid: uuid, arguments: arguments!, result: result)
break break
case "loadData":
self.loadData(uuid: uuid, arguments: arguments!, result: result)
break
case "postUrl":
self.postUrl(uuid: uuid, arguments: arguments!, result: result)
break
case "loadFile": case "loadFile":
self.loadFile(uuid: uuid, arguments: arguments!, result: result) self.loadFile(uuid: uuid, arguments: arguments!, result: result)
break break
...@@ -384,10 +390,34 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin { ...@@ -384,10 +390,34 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
} }
else { else {
result(FlutterError(code: "InAppBrowserFlutterPlugin", message: "url is empty", details: nil)) result(FlutterError(code: "InAppBrowserFlutterPlugin", message: "url is empty", details: nil))
return
} }
result(true) result(true)
} }
public func loadData(uuid: String, arguments: NSDictionary, result: @escaping FlutterResult) {
let webViewController: InAppBrowserWebViewController = self.webViewControllers[uuid] as! InAppBrowserWebViewController
let data = (arguments["data"] as? String)!
let mimeType = (arguments["mimeType"] as? String)!
let encoding = (arguments["encoding"] as? String)!
let baseUrl = (arguments["baseUrl"] as? String)!
webViewController.loadData(data: data, mimeType: mimeType, encoding: encoding, baseUrl: baseUrl)
result(true)
}
public func postUrl(uuid: String, arguments: NSDictionary, result: @escaping FlutterResult) {
let webViewController: InAppBrowserWebViewController = self.webViewControllers[uuid] as! InAppBrowserWebViewController
if let url = arguments["url"] as? String {
let postData = (arguments["postData"] as? FlutterStandardTypedData)!
let absoluteUrl = URL(string: url)!.absoluteURL
webViewController.postUrl(url: absoluteUrl, postData: postData.data, result: result)
}
else {
result(FlutterError(code: "InAppBrowserFlutterPlugin", message: "url is empty", details: nil))
return
}
}
public func loadFile(uuid: String, arguments: NSDictionary, result: @escaping FlutterResult) { public func loadFile(uuid: String, arguments: NSDictionary, result: @escaping FlutterResult) {
let webViewController: InAppBrowserWebViewController = self.webViewControllers[uuid] as! InAppBrowserWebViewController let webViewController: InAppBrowserWebViewController = self.webViewControllers[uuid] as! InAppBrowserWebViewController
if let url = arguments["url"] as? String { if let url = arguments["url"] as? String {
...@@ -404,6 +434,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin { ...@@ -404,6 +434,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
} }
else { else {
result(FlutterError(code: "InAppBrowserFlutterPlugin", message: "url is empty", details: nil)) result(FlutterError(code: "InAppBrowserFlutterPlugin", message: "url is empty", details: nil))
return
} }
result(true) result(true)
} }
...@@ -458,6 +489,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin { ...@@ -458,6 +489,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
func open(inSystem url: URL, result: @escaping FlutterResult) { func open(inSystem url: URL, result: @escaping FlutterResult) {
if !UIApplication.shared.canOpenURL(url) { if !UIApplication.shared.canOpenURL(url) {
result(FlutterError(code: "InAppBrowserFlutterPlugin", message: url.absoluteString + " cannot be opened!", details: nil)) result(FlutterError(code: "InAppBrowserFlutterPlugin", message: url.absoluteString + " cannot be opened!", details: nil))
return
} }
else { else {
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
......
...@@ -189,7 +189,7 @@ class InAppBrowser { ...@@ -189,7 +189,7 @@ class InAppBrowser {
/// - __allowsPictureInPictureMediaPlayback__: Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`. /// - __allowsPictureInPictureMediaPlayback__: Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
/// - __spinner__: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`. /// - __spinner__: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
Future<void> open({String url = "about:blank", Map<String, String> headers = const {}, Map<String, dynamic> options = const {}}) async { Future<void> open({String url = "about:blank", Map<String, String> headers = const {}, Map<String, dynamic> options = const {}}) async {
assert(url != null); assert(url != null && url.isNotEmpty);
this._throwIsAlreadyOpened(message: 'Cannot open $url!'); this._throwIsAlreadyOpened(message: 'Cannot open $url!');
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('uuid', () => uuid); args.putIfAbsent('uuid', () => uuid);
...@@ -233,7 +233,7 @@ class InAppBrowser { ...@@ -233,7 +233,7 @@ class InAppBrowser {
///... ///...
///``` ///```
Future<void> openFile(String assetFilePath, {Map<String, String> headers = const {}, Map<String, dynamic> options = const {}}) async { Future<void> openFile(String assetFilePath, {Map<String, String> headers = const {}, Map<String, dynamic> options = const {}}) async {
assert(assetFilePath != null); assert(assetFilePath != null && assetFilePath.isNotEmpty);
this._throwIsAlreadyOpened(message: 'Cannot open $assetFilePath!'); this._throwIsAlreadyOpened(message: 'Cannot open $assetFilePath!');
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('uuid', () => uuid); args.putIfAbsent('uuid', () => uuid);
...@@ -249,7 +249,7 @@ class InAppBrowser { ...@@ -249,7 +249,7 @@ class InAppBrowser {
///This is a static method that opens an [url] in the system browser. You wont be able to use the [InAppBrowser] methods here! ///This is a static method that opens an [url] in the system browser. You wont be able to use the [InAppBrowser] methods here!
static Future<void> openWithSystemBrowser(String url) async { static Future<void> openWithSystemBrowser(String url) async {
assert(url != null); assert(url != null && url.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('uuid', () => ""); args.putIfAbsent('uuid', () => "");
args.putIfAbsent('url', () => url); args.putIfAbsent('url', () => url);
...@@ -441,7 +441,7 @@ class ChromeSafariBrowser { ...@@ -441,7 +441,7 @@ class ChromeSafariBrowser {
///- __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. ///- __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. ///- __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.
Future<void> open(String url, {Map<String, dynamic> options = const {}, Map<String, String> headersFallback = const {}, Map<String, dynamic> optionsFallback = const {}}) async { Future<void> open(String url, {Map<String, dynamic> options = const {}, Map<String, String> headersFallback = const {}, Map<String, dynamic> optionsFallback = const {}}) async {
assert(url != null); assert(url != null && url.isNotEmpty);
this._throwIsAlreadyOpened(message: 'Cannot open $url!'); this._throwIsAlreadyOpened(message: 'Cannot open $url!');
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('uuid', () => uuid); args.putIfAbsent('uuid', () => uuid);
...@@ -768,7 +768,7 @@ class InAppWebViewController { ...@@ -768,7 +768,7 @@ class InAppWebViewController {
///Loads the given [url] with optional [headers] specified as a map from name to value. ///Loads the given [url] with optional [headers] specified as a map from name to value.
Future<void> loadUrl(String url, {Map<String, String> headers = const {}}) async { Future<void> loadUrl(String url, {Map<String, String> headers = const {}}) async {
assert(url != null); assert(url != null && url.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null) { if (_inAppBrowserUuid != null) {
_inAppBrowser._throwIsNotOpened(message: 'Cannot laod $url!'); _inAppBrowser._throwIsNotOpened(message: 'Cannot laod $url!');
...@@ -779,6 +779,37 @@ class InAppWebViewController { ...@@ -779,6 +779,37 @@ class InAppWebViewController {
await _channel.invokeMethod('loadUrl', args); await _channel.invokeMethod('loadUrl', args);
} }
///Loads the given [url] with [postData] using `POST` method into this WebView.
Future<void> postUrl(String url, Uint8List postData) async {
assert(url != null && url.isNotEmpty);
assert(postData != null);
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null) {
_inAppBrowser._throwIsNotOpened(message: 'Cannot laod $url!');
args.putIfAbsent('uuid', () => _inAppBrowserUuid);
}
args.putIfAbsent('url', () => url);
args.putIfAbsent('postData', () => postData);
await _channel.invokeMethod('postUrl', args);
}
///Loads the given [data] into this WebView, using [baseUrl] as the base URL for the content.
///The [mimeType] parameter specifies the format of the data.
///The [encoding] parameter specifies the encoding of the data.
Future<void> loadData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank"}) async {
assert(data != null);
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null) {
_inAppBrowser._throwIsNotOpened();
args.putIfAbsent('uuid', () => _inAppBrowserUuid);
}
args.putIfAbsent('data', () => data);
args.putIfAbsent('mimeType', () => mimeType);
args.putIfAbsent('encoding', () => encoding);
args.putIfAbsent('baseUrl', () => baseUrl);
await _channel.invokeMethod('loadData', args);
}
///Loads the given [assetFilePath] with optional [headers] specified as a map from name to value. ///Loads the given [assetFilePath] with optional [headers] specified as a map from name to value.
/// ///
///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found! ///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found!
...@@ -809,7 +840,7 @@ class InAppWebViewController { ...@@ -809,7 +840,7 @@ class InAppWebViewController {
///... ///...
///``` ///```
Future<void> loadFile(String assetFilePath, {Map<String, String> headers = const {}}) async { Future<void> loadFile(String assetFilePath, {Map<String, String> headers = const {}}) async {
assert(assetFilePath != null); assert(assetFilePath != null && assetFilePath.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null) { if (_inAppBrowserUuid != null) {
_inAppBrowser._throwIsNotOpened(message: 'Cannot laod $assetFilePath!'); _inAppBrowser._throwIsNotOpened(message: 'Cannot laod $assetFilePath!');
...@@ -1064,8 +1095,6 @@ class InAppLocalhostServer { ...@@ -1064,8 +1095,6 @@ class InAppLocalhostServer {
} }
} }
print(contentType);
request.response.headers.contentType = new ContentType(contentType[0], contentType[1], charset: 'utf-8'); request.response.headers.contentType = new ContentType(contentType[0], contentType[1], charset: 'utf-8');
request.response.add(body); request.response.add(body);
request.response.close(); request.response.close();
......
name: flutter_inappbrowser name: flutter_inappbrowser
description: A Flutter plugin that allows you to add an inline webview or open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser). description: A Flutter plugin that allows you to add an inline webview or open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser).
version: 0.5.1 version: 0.5.2
author: Lorenzo Pichilli <pichillilorenzo@gmail.com> author: Lorenzo Pichilli <pichillilorenzo@gmail.com>
homepage: https://github.com/pichillilorenzo/flutter_inappbrowser homepage: https://github.com/pichillilorenzo/flutter_inappbrowser
......
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