code format
This commit is contained in:
parent
92eba92a6c
commit
00cf46faed
|
@ -40,7 +40,7 @@ void convertToInAppWebView() {
|
||||||
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
||||||
|
|
||||||
final Completer<InAppWebViewController> widgetControllerCompleter =
|
final Completer<InAppWebViewController> widgetControllerCompleter =
|
||||||
Completer<InAppWebViewController>();
|
Completer<InAppWebViewController>();
|
||||||
final Completer<String> loadedUrl = Completer<String>();
|
final Completer<String> loadedUrl = Completer<String>();
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
|
@ -61,11 +61,13 @@ void convertToInAppWebView() {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final InAppWebViewController widgetController = await widgetControllerCompleter.future;
|
final InAppWebViewController widgetController =
|
||||||
|
await widgetControllerCompleter.future;
|
||||||
|
|
||||||
expect(headlessWebView.isRunning(), false);
|
expect(headlessWebView.isRunning(), false);
|
||||||
|
|
||||||
expect((await widgetController.getUrl())?.toString(), TEST_CROSS_PLATFORM_URL_1.toString());
|
expect((await widgetController.getUrl())?.toString(),
|
||||||
|
TEST_CROSS_PLATFORM_URL_1.toString());
|
||||||
|
|
||||||
await widgetController.loadUrl(
|
await widgetController.loadUrl(
|
||||||
urlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_2));
|
urlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_2));
|
||||||
|
|
|
@ -722,4 +722,4 @@ extension InternalHeadlessInAppWebView on HeadlessInAppWebView {
|
||||||
_started = false;
|
_started = false;
|
||||||
_running = false;
|
_running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,7 +625,10 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
webViewHtmlElement.initialUrlRequest = widget.initialUrlRequest;
|
webViewHtmlElement.initialUrlRequest = widget.initialUrlRequest;
|
||||||
webViewHtmlElement.initialFile = widget.initialFile;
|
webViewHtmlElement.initialFile = widget.initialFile;
|
||||||
webViewHtmlElement.initialData = widget.initialData;
|
webViewHtmlElement.initialData = widget.initialData;
|
||||||
webViewHtmlElement.headlessWebViewId = widget.headlessWebView?.isRunning() ?? false ? widget.headlessWebView?.id : null;
|
webViewHtmlElement.headlessWebViewId =
|
||||||
|
widget.headlessWebView?.isRunning() ?? false
|
||||||
|
? widget.headlessWebView?.id
|
||||||
|
: null;
|
||||||
webViewHtmlElement.prepare();
|
webViewHtmlElement.prepare();
|
||||||
if (webViewHtmlElement.headlessWebViewId == null) {
|
if (webViewHtmlElement.headlessWebViewId == null) {
|
||||||
webViewHtmlElement.makeInitialLoad();
|
webViewHtmlElement.makeInitialLoad();
|
||||||
|
@ -672,7 +675,10 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
'initialSettings': initialSettings,
|
'initialSettings': initialSettings,
|
||||||
'contextMenu': widget.contextMenu?.toMap() ?? {},
|
'contextMenu': widget.contextMenu?.toMap() ?? {},
|
||||||
'windowId': widget.windowId,
|
'windowId': widget.windowId,
|
||||||
'headlessWebViewId': widget.headlessWebView?.isRunning() ?? false ? widget.headlessWebView?.id : null,
|
'headlessWebViewId':
|
||||||
|
widget.headlessWebView?.isRunning() ?? false
|
||||||
|
? widget.headlessWebView?.id
|
||||||
|
: null,
|
||||||
'implementation': widget.implementation.toNativeValue(),
|
'implementation': widget.implementation.toNativeValue(),
|
||||||
'initialUserScripts':
|
'initialUserScripts':
|
||||||
widget.initialUserScripts?.map((e) => e.toMap()).toList() ??
|
widget.initialUserScripts?.map((e) => e.toMap()).toList() ??
|
||||||
|
@ -700,7 +706,9 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
'initialSettings': initialSettings,
|
'initialSettings': initialSettings,
|
||||||
'contextMenu': widget.contextMenu?.toMap() ?? {},
|
'contextMenu': widget.contextMenu?.toMap() ?? {},
|
||||||
'windowId': widget.windowId,
|
'windowId': widget.windowId,
|
||||||
'headlessWebViewId': widget.headlessWebView?.isRunning() ?? false ? widget.headlessWebView?.id : null,
|
'headlessWebViewId': widget.headlessWebView?.isRunning() ?? false
|
||||||
|
? widget.headlessWebView?.id
|
||||||
|
: null,
|
||||||
'implementation': widget.implementation.toNativeValue(),
|
'implementation': widget.implementation.toNativeValue(),
|
||||||
'initialUserScripts':
|
'initialUserScripts':
|
||||||
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
|
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
|
||||||
|
@ -723,7 +731,9 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
'initialSettings': initialSettings,
|
'initialSettings': initialSettings,
|
||||||
'contextMenu': widget.contextMenu?.toMap() ?? {},
|
'contextMenu': widget.contextMenu?.toMap() ?? {},
|
||||||
'windowId': widget.windowId,
|
'windowId': widget.windowId,
|
||||||
'headlessWebViewId': widget.headlessWebView?.isRunning() ?? false ? widget.headlessWebView?.id : null,
|
'headlessWebViewId': widget.headlessWebView?.isRunning() ?? false
|
||||||
|
? widget.headlessWebView?.id
|
||||||
|
: null,
|
||||||
'implementation': widget.implementation.toNativeValue(),
|
'implementation': widget.implementation.toNativeValue(),
|
||||||
'initialUserScripts':
|
'initialUserScripts':
|
||||||
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
|
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
|
||||||
|
@ -754,7 +764,9 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onPlatformViewCreated(int id) {
|
void _onPlatformViewCreated(int id) {
|
||||||
final viewId = (!kIsWeb && (widget.headlessWebView?.isRunning() ?? false)) ? widget.headlessWebView?.id : id;
|
final viewId = (!kIsWeb && (widget.headlessWebView?.isRunning() ?? false))
|
||||||
|
? widget.headlessWebView?.id
|
||||||
|
: id;
|
||||||
widget.headlessWebView?.internalDispose();
|
widget.headlessWebView?.internalDispose();
|
||||||
_controller = InAppWebViewController(viewId, widget);
|
_controller = InAppWebViewController(viewId, widget);
|
||||||
widget.pullToRefreshController?.initMethodChannel(viewId);
|
widget.pullToRefreshController?.initMethodChannel(viewId);
|
||||||
|
|
|
@ -62,8 +62,10 @@ class HeadlessInAppWebViewManager {
|
||||||
webView.iframeContainer.style.display = 'none';
|
webView.iframeContainer.style.display = 'none';
|
||||||
Map<String, num>? initialSize = params["initialSize"]?.cast<String, num>();
|
Map<String, num>? initialSize = params["initialSize"]?.cast<String, num>();
|
||||||
if (initialSize != null) {
|
if (initialSize != null) {
|
||||||
webView.iframeContainer.style.width = initialSize["width"].toString() + 'px';
|
webView.iframeContainer.style.width =
|
||||||
webView.iframeContainer.style.height = initialSize["height"].toString() + 'px';
|
initialSize["width"].toString() + 'px';
|
||||||
|
webView.iframeContainer.style.height =
|
||||||
|
initialSize["height"].toString() + 'px';
|
||||||
}
|
}
|
||||||
Map<String, dynamic> initialSettings =
|
Map<String, dynamic> initialSettings =
|
||||||
params["initialSettings"].cast<String, dynamic>();
|
params["initialSettings"].cast<String, dynamic>();
|
||||||
|
|
|
@ -185,7 +185,8 @@ class InAppWebViewWebElement implements Disposable {
|
||||||
|
|
||||||
void prepare() {
|
void prepare() {
|
||||||
if (headlessWebViewId != null) {
|
if (headlessWebViewId != null) {
|
||||||
final headlessWebView = HeadlessInAppWebViewManager.webViews[headlessWebViewId!];
|
final headlessWebView =
|
||||||
|
HeadlessInAppWebViewManager.webViews[headlessWebViewId!];
|
||||||
if (headlessWebView != null && headlessWebView.webView != null) {
|
if (headlessWebView != null && headlessWebView.webView != null) {
|
||||||
final webView = headlessWebView.disposeAndGetFlutterWebView();
|
final webView = headlessWebView.disposeAndGetFlutterWebView();
|
||||||
if (webView != null) {
|
if (webView != null) {
|
||||||
|
@ -211,15 +212,16 @@ class InAppWebViewWebElement implements Disposable {
|
||||||
|
|
||||||
Set<Sandbox> sandbox = Set.from(Sandbox.values);
|
Set<Sandbox> sandbox = Set.from(Sandbox.values);
|
||||||
|
|
||||||
if (settings!.javaScriptEnabled != null && !settings!.javaScriptEnabled!) {
|
if (settings!.javaScriptEnabled != null &&
|
||||||
|
!settings!.javaScriptEnabled!) {
|
||||||
sandbox.remove(Sandbox.ALLOW_SCRIPTS);
|
sandbox.remove(Sandbox.ALLOW_SCRIPTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
iframe.allow = settings!.iframeAllow ?? iframe.allow;
|
iframe.allow = settings!.iframeAllow ?? iframe.allow;
|
||||||
iframe.allowFullscreen =
|
iframe.allowFullscreen =
|
||||||
settings!.iframeAllowFullscreen ?? iframe.allowFullscreen;
|
settings!.iframeAllowFullscreen ?? iframe.allowFullscreen;
|
||||||
iframe.referrerPolicy =
|
iframe.referrerPolicy = settings!.iframeReferrerPolicy?.toNativeValue() ??
|
||||||
settings!.iframeReferrerPolicy?.toNativeValue() ?? iframe.referrerPolicy;
|
iframe.referrerPolicy;
|
||||||
iframe.name = settings!.iframeName ?? iframe.name;
|
iframe.name = settings!.iframeName ?? iframe.name;
|
||||||
iframe.csp = settings!.iframeCsp ?? iframe.csp;
|
iframe.csp = settings!.iframeCsp ?? iframe.csp;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue