Reverted calling handler.post on Android when a WebView is created, Fixed iOS extra bottom padding when opening the keyboard, fix #429
This commit is contained in:
parent
3bb05cf03b
commit
b8ec14d6b6
@ -1,3 +1,9 @@
|
||||
## 4.0.0+3
|
||||
|
||||
- Reverted calling `handler.post` on Android when a WebView is created
|
||||
- Fixed iOS extra bottom padding when opening the keyboard
|
||||
- Fixed "Build for web not working – The integer literal 9223372036854775807 can't be represented exactly in JavaScript" [#429](https://github.com/pichillilorenzo/flutter_inappwebview/issues/429)
|
||||
|
||||
## 4.0.0
|
||||
|
||||
- Updated `onCreateWindow`, `onJsAlert`, `onJsConfirm`, `onJsPrompt` webview events
|
||||
|
@ -14,7 +14,11 @@
|
||||
|
||||
A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
|
||||
|
||||
### Requirements
|
||||
## Articles/Resources
|
||||
|
||||
- [InAppWebView: The Real Power of WebViews in Flutter](https://medium.com/flutter-community/inappwebview-the-real-power-of-webviews-in-flutter-c6d52374209d?source=friends_link&sk=cb74487219bcd85e610a670ee0b447d0)
|
||||
|
||||
## Requirements
|
||||
|
||||
- Dart sdk: ">=2.7.0 <3.0.0"
|
||||
- Flutter: ">=1.12.13+hotfix.5"
|
||||
|
@ -108,23 +108,17 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
|
||||
}
|
||||
}
|
||||
|
||||
final String finalInitialUrl = initialUrl;
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (initialData != null) {
|
||||
String data = initialData.get("data");
|
||||
String mimeType = initialData.get("mimeType");
|
||||
String encoding = initialData.get("encoding");
|
||||
String baseUrl = initialData.get("baseUrl");
|
||||
String historyUrl = initialData.get("historyUrl");
|
||||
webView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
|
||||
}
|
||||
else
|
||||
webView.loadUrl(finalInitialUrl, initialHeaders);
|
||||
}
|
||||
});
|
||||
if (initialData != null) {
|
||||
String data = initialData.get("data");
|
||||
String mimeType = initialData.get("mimeType");
|
||||
String encoding = initialData.get("encoding");
|
||||
String baseUrl = initialData.get("baseUrl");
|
||||
String historyUrl = initialData.get("historyUrl");
|
||||
webView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
|
||||
}
|
||||
else {
|
||||
webView.loadUrl(initialUrl, initialHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
if (containerView == null && id instanceof String) {
|
||||
|
@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]}],"android":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[]},"dependencyGraph":[{"name":"e2e","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-06-30 14:26:38.633976","version":"1.17.4"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]},{"name":"webview_flutter","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/","dependencies":[]}],"android":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]},{"name":"webview_flutter","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"url_launcher_web","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"e2e","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-07-02 09:44:29.597292","version":"1.17.4"}
|
@ -259,6 +259,8 @@
|
||||
"${BUILT_PRODUCTS_DIR}/flutter_downloader/flutter_downloader.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/flutter_inappwebview/flutter_inappwebview.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/webview_flutter/webview_flutter.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
@ -267,6 +269,8 @@
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_downloader.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_inappwebview.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
|
@ -3,6 +3,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'main.dart';
|
||||
|
||||
@ -86,7 +87,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
||||
initialOptions: InAppWebViewGroupOptions(
|
||||
crossPlatform: InAppWebViewOptions(
|
||||
debuggingEnabled: true,
|
||||
useShouldOverrideUrlLoading: true
|
||||
useShouldOverrideUrlLoading: true,
|
||||
),
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
@ -100,7 +101,22 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
||||
});
|
||||
},
|
||||
shouldOverrideUrlLoading: (controller, shouldOverrideUrlLoadingRequest) async {
|
||||
print("shouldOverrideUrlLoading");
|
||||
var url = shouldOverrideUrlLoadingRequest.url;
|
||||
var uri = Uri.parse(url);
|
||||
|
||||
if (!["http", "https", "file",
|
||||
"chrome", "data", "javascript",
|
||||
"about"].contains(uri.scheme)) {
|
||||
if (await canLaunch(url)) {
|
||||
// Launch the App
|
||||
await launch(
|
||||
url,
|
||||
);
|
||||
// and cancel the request
|
||||
return ShouldOverrideUrlLoadingAction.CANCEL;
|
||||
}
|
||||
}
|
||||
|
||||
return ShouldOverrideUrlLoadingAction.ALLOW;
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) async {
|
||||
|
@ -23,7 +23,7 @@ dependencies:
|
||||
flutter_downloader: ^1.4.4
|
||||
path_provider: ^1.6.9
|
||||
permission_handler: ^5.0.0+hotfix.6
|
||||
# webview_flutter: ^0.3.22+1
|
||||
url_launcher: ^5.4.11
|
||||
# connectivity: ^0.4.5+6
|
||||
flutter_inappwebview:
|
||||
path: ../
|
||||
|
@ -869,6 +869,26 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
|
||||
self.longPressRecognizer!.addTarget(self, action: #selector(longPressGestureDetected))
|
||||
}
|
||||
|
||||
override public var frame: CGRect {
|
||||
get {
|
||||
return super.frame
|
||||
}
|
||||
set {
|
||||
super.frame = newValue
|
||||
|
||||
self.scrollView.contentInset = UIEdgeInsets.zero;
|
||||
if #available(iOS 11, *) {
|
||||
// Above iOS 11, adjust contentInset to compensate the adjustedContentInset so the sum will
|
||||
// always be 0.
|
||||
if (scrollView.adjustedContentInset != UIEdgeInsets.zero) {
|
||||
let insetToAdjust = self.scrollView.adjustedContentInset;
|
||||
scrollView.contentInset = UIEdgeInsets(top: -insetToAdjust.top, left: -insetToAdjust.left,
|
||||
bottom: -insetToAdjust.bottom, right: -insetToAdjust.right);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
required public init(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)!
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ class ASN1DERDecoder {
|
||||
|
||||
static List<int> loadSubContent({@required Iterator<int> iterator}) {
|
||||
var len = getContentLength(iterator: iterator);
|
||||
int int64MaxValue = 9223372036854775807;
|
||||
int int64MaxValue = double.maxFinite.toInt();
|
||||
|
||||
if (len >= BigInt.from(int64MaxValue)) {
|
||||
return <int>[];
|
||||
|
@ -198,7 +198,7 @@ class HeadlessInAppWebView implements WebView {
|
||||
|
||||
@override
|
||||
final Future<bool> Function(InAppWebViewController controller,
|
||||
CreateWindowRequest onCreateWindowRequest) onCreateWindow;
|
||||
CreateWindowRequest createWindowRequest) onCreateWindow;
|
||||
|
||||
@override
|
||||
final void Function(InAppWebViewController controller) onCloseWindow;
|
||||
|
@ -347,6 +347,8 @@ class InAppBrowser {
|
||||
///
|
||||
///[createWindowRequest] represents the request.
|
||||
///
|
||||
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewOptions.javaScriptCanOpenWindowsAutomatically] option to `true`.
|
||||
///
|
||||
///**NOTE**: on Android you need to set [AndroidInAppWebViewOptions.supportMultipleWindows] option to `true`.
|
||||
///
|
||||
///**NOTE**: on iOS, setting these initial options: [InAppWebViewOptions.supportZoom], [InAppWebViewOptions.useOnLoadResource], [InAppWebViewOptions.useShouldInterceptAjaxRequest],
|
||||
|
@ -162,7 +162,7 @@ class InAppWebView extends StatefulWidget implements WebView {
|
||||
|
||||
@override
|
||||
final Future<bool> Function(InAppWebViewController controller,
|
||||
CreateWindowRequest onCreateWindowRequest) onCreateWindow;
|
||||
CreateWindowRequest createWindowRequest) onCreateWindow;
|
||||
|
||||
@override
|
||||
final void Function(InAppWebViewController controller) onCloseWindow;
|
||||
|
@ -138,6 +138,8 @@ abstract class WebView {
|
||||
///
|
||||
///[createWindowRequest] represents the request.
|
||||
///
|
||||
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewOptions.javaScriptCanOpenWindowsAutomatically] option to `true`.
|
||||
///
|
||||
///**NOTE**: on Android you need to set [AndroidInAppWebViewOptions.supportMultipleWindows] option to `true`.
|
||||
///
|
||||
///**NOTE**: on iOS, setting these initial options: [InAppWebViewOptions.supportZoom], [InAppWebViewOptions.useOnLoadResource], [InAppWebViewOptions.useShouldInterceptAjaxRequest],
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: flutter_inappwebview
|
||||
description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
|
||||
version: 4.0.0
|
||||
version: 4.0.0+3
|
||||
homepage: https://github.com/pichillilorenzo/flutter_inappwebview
|
||||
|
||||
environment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user