Commit 219f079a authored by pichillilorenzo's avatar pichillilorenzo

Fixed README.md and method documentation

parent 23194ac6
This diff is collapsed.
## 1.1.1
- Fixed README.md and `addJavaScriptHandler` method documentation
## 1.1.0
- Breaking change for `addJavaScriptHandler` and `removeJavaScriptHandler` methods.
......
......@@ -575,8 +575,9 @@ that can be used to get the json result returned by `JavaScriptHandlerCallback`.
In this case, simply return data that you want to send and it will be automatically json encoded using `jsonEncode` from the `dart:convert` library.
So, on the JavaScript side, to get data coming from the Dart side, you will use:
```javascript
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
```html
<script>
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
console.log(result, typeof result);
console.log(JSON.stringify(result));
......@@ -586,7 +587,18 @@ window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
console.log(result, typeof result);
console.log(JSON.stringify(result));
});
});
});
</script>
```
Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
```dart
// Inject JavaScript that will receive data back from Flutter
inAppWebViewController.injectScriptCode("""
window.flutter_inappbrowser.callHandler('test', 'Text from Javascript').then(function(result) {
console.log(result);
});
""");
```
```dart
......@@ -599,7 +611,7 @@ Removes a JavaScript message handler previously added with the `addJavaScriptHan
Returns the value associated with `handlerName` before it was removed.
Returns `null` if `handlerName` was not found.
```dart
inAppWebViewController.removeJavaScriptHandler(String handlerName, int index);
inAppWebViewController.removeJavaScriptHandler(String handlerName);
```
#### Future\<Uint8List\> InAppWebViewController.takeScreenshot
......
......@@ -1177,7 +1177,8 @@ class InAppWebViewController {
///In this case, simply return data that you want to send and it will be automatically json encoded using [jsonEncode] from the `dart:convert` library.
///
///So, on the JavaScript side, to get data coming from the Dart side, you will use:
///```javascript
///```html
///<script>
/// window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
/// window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
/// console.log(result, typeof result);
......@@ -1189,6 +1190,17 @@ class InAppWebViewController {
/// console.log(JSON.stringify(result));
/// });
/// });
///</script>
///```
///
///Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
///```dart
/// // Inject JavaScript that will receive data back from Flutter
/// inAppWebViewController.injectScriptCode("""
/// window.flutter_inappbrowser.callHandler('test', 'Text from Javascript').then(function(result) {
/// console.log(result);
/// });
/// """);
///```
void addJavaScriptHandler(String handlerName, JavaScriptHandlerCallback callback) {
this.javaScriptHandlersMap[handlerName] = (callback);
......
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).
version: 1.1.0
version: 1.1.1
author: Lorenzo Pichilli <pichillilorenzo@gmail.com>
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