code format

This commit is contained in:
Lorenzo Pichilli 2022-10-20 16:50:11 +02:00
parent 92eba92a6c
commit 00cf46faed
5 changed files with 33 additions and 15 deletions

View File

@ -40,7 +40,7 @@ void convertToInAppWebView() {
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
final Completer<InAppWebViewController> widgetControllerCompleter =
Completer<InAppWebViewController>();
Completer<InAppWebViewController>();
final Completer<String> loadedUrl = Completer<String>();
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((await widgetController.getUrl())?.toString(), TEST_CROSS_PLATFORM_URL_1.toString());
expect((await widgetController.getUrl())?.toString(),
TEST_CROSS_PLATFORM_URL_1.toString());
await widgetController.loadUrl(
urlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_2));

View File

@ -722,4 +722,4 @@ extension InternalHeadlessInAppWebView on HeadlessInAppWebView {
_started = false;
_running = false;
}
}
}

View File

@ -625,7 +625,10 @@ class _InAppWebViewState extends State<InAppWebView> {
webViewHtmlElement.initialUrlRequest = widget.initialUrlRequest;
webViewHtmlElement.initialFile = widget.initialFile;
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();
if (webViewHtmlElement.headlessWebViewId == null) {
webViewHtmlElement.makeInitialLoad();
@ -672,7 +675,10 @@ class _InAppWebViewState extends State<InAppWebView> {
'initialSettings': initialSettings,
'contextMenu': widget.contextMenu?.toMap() ?? {},
'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(),
'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ??
@ -700,7 +706,9 @@ class _InAppWebViewState extends State<InAppWebView> {
'initialSettings': initialSettings,
'contextMenu': widget.contextMenu?.toMap() ?? {},
'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(),
'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
@ -723,7 +731,9 @@ class _InAppWebViewState extends State<InAppWebView> {
'initialSettings': initialSettings,
'contextMenu': widget.contextMenu?.toMap() ?? {},
'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(),
'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
@ -754,7 +764,9 @@ class _InAppWebViewState extends State<InAppWebView> {
}
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();
_controller = InAppWebViewController(viewId, widget);
widget.pullToRefreshController?.initMethodChannel(viewId);

View File

@ -62,8 +62,10 @@ class HeadlessInAppWebViewManager {
webView.iframeContainer.style.display = 'none';
Map<String, num>? initialSize = params["initialSize"]?.cast<String, num>();
if (initialSize != null) {
webView.iframeContainer.style.width = initialSize["width"].toString() + 'px';
webView.iframeContainer.style.height = initialSize["height"].toString() + 'px';
webView.iframeContainer.style.width =
initialSize["width"].toString() + 'px';
webView.iframeContainer.style.height =
initialSize["height"].toString() + 'px';
}
Map<String, dynamic> initialSettings =
params["initialSettings"].cast<String, dynamic>();

View File

@ -185,7 +185,8 @@ class InAppWebViewWebElement implements Disposable {
void prepare() {
if (headlessWebViewId != null) {
final headlessWebView = HeadlessInAppWebViewManager.webViews[headlessWebViewId!];
final headlessWebView =
HeadlessInAppWebViewManager.webViews[headlessWebViewId!];
if (headlessWebView != null && headlessWebView.webView != null) {
final webView = headlessWebView.disposeAndGetFlutterWebView();
if (webView != null) {
@ -211,15 +212,16 @@ class InAppWebViewWebElement implements Disposable {
Set<Sandbox> sandbox = Set.from(Sandbox.values);
if (settings!.javaScriptEnabled != null && !settings!.javaScriptEnabled!) {
if (settings!.javaScriptEnabled != null &&
!settings!.javaScriptEnabled!) {
sandbox.remove(Sandbox.ALLOW_SCRIPTS);
}
iframe.allow = settings!.iframeAllow ?? iframe.allow;
iframe.allowFullscreen =
settings!.iframeAllowFullscreen ?? iframe.allowFullscreen;
iframe.referrerPolicy =
settings!.iframeReferrerPolicy?.toNativeValue() ?? iframe.referrerPolicy;
iframe.referrerPolicy = settings!.iframeReferrerPolicy?.toNativeValue() ??
iframe.referrerPolicy;
iframe.name = settings!.iframeName ?? iframe.name;
iframe.csp = settings!.iframeCsp ?? iframe.csp;