@@ -146,41 +146,39 @@ class WebViewState extends EWidgetState<EnsembleWebView> with CookieMethods {
146
146
headers: widget.controller.headers,
147
147
)
148
148
: null ,
149
- initialOptions: InAppWebViewGroupOptions (
150
- crossPlatform: InAppWebViewOptions (
151
- useShouldOverrideUrlLoading: true ,
152
- mediaPlaybackRequiresUserGesture: false ,
153
- javaScriptEnabled: true ,
154
- useOnLoadResource: true ,
155
- clearCache: true ,
156
- transparentBackground: true ,
157
- supportZoom: true ,
158
- preferredContentMode: UserPreferredContentMode .MOBILE ,
159
- ),
160
- android: AndroidInAppWebViewOptions (
161
- useHybridComposition: true ,
162
- hardwareAcceleration: true ,
163
- mixedContentMode:
164
- AndroidMixedContentMode .MIXED_CONTENT_ALWAYS_ALLOW ,
165
- safeBrowsingEnabled: false ,
166
- domStorageEnabled: true ,
167
- databaseEnabled: true ,
168
- supportMultipleWindows: true ,
169
- builtInZoomControls: true ,
170
- displayZoomControls: false ,
171
- allowFileAccess: true ,
172
- useWideViewPort: true ,
173
- allowContentAccess: true ,
174
- loadWithOverviewMode: true ,
175
- ),
176
- ios: IOSInAppWebViewOptions (
177
- allowsInlineMediaPlayback: true ,
178
- allowsBackForwardNavigationGestures: true ,
179
- enableViewportScale: true ,
180
- suppressesIncrementalRendering: false ,
181
- allowsPictureInPictureMediaPlayback: true ,
182
- isFraudulentWebsiteWarningEnabled: false ,
183
- ),
149
+ initialSettings: InAppWebViewSettings (
150
+ // Cross Platform Settings
151
+ useShouldOverrideUrlLoading: true ,
152
+ mediaPlaybackRequiresUserGesture: false ,
153
+ javaScriptEnabled: true ,
154
+ useOnLoadResource: true ,
155
+ transparentBackground: true ,
156
+ supportZoom: true ,
157
+ clearCache: true ,
158
+ preferredContentMode: UserPreferredContentMode .MOBILE ,
159
+
160
+ // Android Specific Settings
161
+ useHybridComposition: true ,
162
+ hardwareAcceleration: true ,
163
+ mixedContentMode: MixedContentMode .MIXED_CONTENT_ALWAYS_ALLOW ,
164
+ safeBrowsingEnabled: false ,
165
+ domStorageEnabled: true ,
166
+ databaseEnabled: true ,
167
+ supportMultipleWindows: true ,
168
+ builtInZoomControls: true ,
169
+ displayZoomControls: false ,
170
+ allowFileAccess: true ,
171
+ useWideViewPort: true ,
172
+ allowContentAccess: true ,
173
+ loadWithOverviewMode: true ,
174
+
175
+ // iOS Specific Settings
176
+ allowsInlineMediaPlayback: true ,
177
+ allowsBackForwardNavigationGestures: true ,
178
+ enableViewportScale: true ,
179
+ suppressesIncrementalRendering: false ,
180
+ allowsPictureInPictureMediaPlayback: true ,
181
+ isFraudulentWebsiteWarningEnabled: false ,
184
182
),
185
183
gestureRecognizers: gestureRecognizers,
186
184
onWebViewCreated: (controller) async {
@@ -234,9 +232,17 @@ class WebViewState extends EWidgetState<EnsembleWebView> with CookieMethods {
234
232
setState (
235
233
() => widget.controller.error = "Error loading html content" );
236
234
},
235
+ onCreateWindow: (controller, createWindowAction) async {
236
+ // Get the URL from the creation request
237
+ final url = createWindowAction.request.url? .toString ();
238
+ if (url != null ) {
239
+ // Load the URL in the current WebView instead of creating a new window
240
+ await controller.loadUrl (urlRequest: URLRequest (url: WebUri (url)));
241
+ }
242
+ return true ;
243
+ },
237
244
shouldOverrideUrlLoading: (controller, navigationAction) async {
238
245
final url = navigationAction.request.url? .toString () ?? '' ;
239
-
240
246
WebViewNavigationEvent event = WebViewNavigationEvent (widget, url);
241
247
if (widget.controller.onNavigationRequest != null ) {
242
248
ScreenController ().executeAction (
0 commit comments