prepare method
void
prepare()
Implementation
void prepare() {
if (headlessWebViewId != null) {
final headlessWebView =
HeadlessInAppWebViewManager.webViews[headlessWebViewId!];
if (headlessWebView != null && headlessWebView.webView != null) {
final webView = headlessWebView.disposeAndGetFlutterWebView();
if (webView != null) {
webView.iframe.id = iframe.id;
iframe.remove();
iframeContainer.append(webView.iframe);
iframe = webView.iframe;
initialSettings = webView.initialSettings;
settings = webView.settings;
initialUrlRequest = webView.initialUrlRequest;
initialData = webView.initialData;
initialFile = webView.initialFile;
jsWebView = flutterInAppWebView?.createFlutterInAppWebView(
_viewId, iframe, iframeContainer);
}
}
}
if (headlessWebViewId == null && settings == null) {
settings = initialSettings ?? InAppWebViewSettings();
Set<Sandbox> sandbox = Set.from(Sandbox.values);
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.name = settings!.iframeName ?? iframe.name;
iframe.csp = settings!.iframeCsp ?? iframe.csp;
if (settings!.iframeSandbox != null &&
settings!.iframeSandbox != Sandbox.ALLOW_ALL) {
iframe.setAttribute("sandbox",
settings!.iframeSandbox!.map((e) => e.toNativeValue()).join(" "));
} else if (settings!.iframeSandbox == Sandbox.ALLOW_ALL) {
iframe.removeAttribute("sandbox");
} else if (sandbox != Sandbox.values) {
iframe.setAttribute(
"sandbox", sandbox.map((e) => e.toNativeValue()).join(" "));
settings!.iframeSandbox = sandbox;
}
}
jsWebView?.prepare(settings?.toMap().jsify());
}