initial windows implementation #460

This commit is contained in:
unknown 2024-01-31 14:44:18 +01:00
parent a6b9a959e1
commit 981c0356b8
35 changed files with 392 additions and 399 deletions

View File

@ -45,8 +45,8 @@ class CookieManager {
return _instance!; return _instance!;
} else { } else {
return CookieManager.fromPlatformCreationParams( return CookieManager.fromPlatformCreationParams(
PlatformCookieManagerCreationParams(webViewEnvironment: webViewEnvironment.platform) PlatformCookieManagerCreationParams(
); webViewEnvironment: webViewEnvironment.platform));
} }
} }

View File

@ -18,22 +18,22 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
/// Constructs a [InAppBrowser]. /// Constructs a [InAppBrowser].
/// ///
/// {@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser} /// {@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser}
InAppBrowser( InAppBrowser({
{ContextMenu? contextMenu, ContextMenu? contextMenu,
PullToRefreshController? pullToRefreshController, PullToRefreshController? pullToRefreshController,
FindInteractionController? findInteractionController, FindInteractionController? findInteractionController,
UnmodifiableListView<UserScript>? initialUserScripts, UnmodifiableListView<UserScript>? initialUserScripts,
int? windowId, int? windowId,
WebViewEnvironment? webViewEnvironment, WebViewEnvironment? webViewEnvironment,
}) }) : this.fromPlatformCreationParams(
: this.fromPlatformCreationParams(
PlatformInAppBrowserCreationParams( PlatformInAppBrowserCreationParams(
contextMenu: contextMenu, contextMenu: contextMenu,
pullToRefreshController: pullToRefreshController?.platform, pullToRefreshController: pullToRefreshController?.platform,
findInteractionController: findInteractionController?.platform, findInteractionController: findInteractionController?.platform,
initialUserScripts: initialUserScripts, initialUserScripts: initialUserScripts,
windowId: windowId, windowId: windowId,
webViewEnvironment: webViewEnvironment?.platform,), webViewEnvironment: webViewEnvironment?.platform,
),
); );
/// Constructs a [InAppBrowser] from creation params for a specific /// Constructs a [InAppBrowser] from creation params for a specific

View File

@ -488,15 +488,21 @@ class InAppWebViewController {
Future<void> openDevTools() => platform.openDevTools(); Future<void> openDevTools() => platform.openDevTools();
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.callDevToolsProtocolMethod} ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.callDevToolsProtocolMethod}
Future<dynamic> callDevToolsProtocolMethod({required String methodName, Map<String, dynamic>? parameters}) => Future<dynamic> callDevToolsProtocolMethod(
platform.callDevToolsProtocolMethod(methodName: methodName, parameters: parameters); {required String methodName, Map<String, dynamic>? parameters}) =>
platform.callDevToolsProtocolMethod(
methodName: methodName, parameters: parameters);
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addDevToolsProtocolEventListener} ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addDevToolsProtocolEventListener}
Future<void> addDevToolsProtocolEventListener({required String eventName, required Function(dynamic data) callback}) => Future<void> addDevToolsProtocolEventListener(
platform.addDevToolsProtocolEventListener(eventName: eventName, callback: callback); {required String eventName,
required Function(dynamic data) callback}) =>
platform.addDevToolsProtocolEventListener(
eventName: eventName, callback: callback);
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeDevToolsProtocolEventListener} ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeDevToolsProtocolEventListener}
Future<void> removeDevToolsProtocolEventListener({required String eventName}) => Future<void> removeDevToolsProtocolEventListener(
{required String eventName}) =>
platform.removeDevToolsProtocolEventListener(eventName: eventName); platform.removeDevToolsProtocolEventListener(eventName: eventName);
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getIFrameId} ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getIFrameId}

View File

@ -27,16 +27,22 @@ class WebViewEnvironment {
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.create} ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.create}
static Future<WebViewEnvironment> create( static Future<WebViewEnvironment> create(
{WebViewEnvironmentSettings? settings}) async { {WebViewEnvironmentSettings? settings}) async {
return WebViewEnvironment.fromPlatform(platform: await PlatformWebViewEnvironment.static().create(settings: settings)); return WebViewEnvironment.fromPlatform(
platform: await PlatformWebViewEnvironment.static()
.create(settings: settings));
} }
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion} ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
static Future<String?> getAvailableVersion( static Future<String?> getAvailableVersion(
{String? browserExecutableFolder}) => PlatformWebViewEnvironment.static().getAvailableVersion(browserExecutableFolder: browserExecutableFolder); {String? browserExecutableFolder}) =>
PlatformWebViewEnvironment.static().getAvailableVersion(
browserExecutableFolder: browserExecutableFolder);
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion} ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
static Future<int?> compareBrowserVersions( static Future<int?> compareBrowserVersions(
{required String version1, required String version2}) => PlatformWebViewEnvironment.static().compareBrowserVersions(version1: version1, version2: version2); {required String version1, required String version2}) =>
PlatformWebViewEnvironment.static()
.compareBrowserVersions(version1: version1, version2: version2);
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose} ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose}
Future<void> dispose() => platform.dispose(); Future<void> dispose() => platform.dispose();

View File

@ -107,189 +107,124 @@ class InAppBrowserSettings_
bool? hidden; bool? hidden;
///Set to `true` to hide the toolbar at the top of the WebView. The default value is `false`. ///Set to `true` to hide the toolbar at the top of the WebView. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
AndroidPlatform(), platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
IOSPlatform(),
MacOSPlatform()
])
bool? hideToolbarTop; bool? hideToolbarTop;
///Set the custom background color of the toolbar at the top. ///Set the custom background color of the toolbar at the top.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
AndroidPlatform(), platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
IOSPlatform(),
MacOSPlatform()
])
Color_? toolbarTopBackgroundColor; Color_? toolbarTopBackgroundColor;
///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`. ///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
AndroidPlatform(), platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
IOSPlatform(),
MacOSPlatform()
])
bool? hideUrlBar; bool? hideUrlBar;
///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`. ///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
AndroidPlatform(), platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
IOSPlatform(),
MacOSPlatform()
])
bool? hideProgressBar; bool? hideProgressBar;
///Set to `true` to hide the default menu items. The default value is `false`. ///Set to `true` to hide the default menu items. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
AndroidPlatform(), platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
IOSPlatform(),
MacOSPlatform()
])
bool? hideDefaultMenuItems; bool? hideDefaultMenuItems;
///Set to `true` if you want the title should be displayed. The default value is `false`. ///Set to `true` if you want the title should be displayed. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [AndroidPlatform()])
AndroidPlatform()
])
bool? hideTitleBar; bool? hideTitleBar;
///Set the action bar's title. ///Set the action bar's title.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
AndroidPlatform(), platforms: [AndroidPlatform(), MacOSPlatform(), WindowsPlatform()])
MacOSPlatform(),
WindowsPlatform()
])
String? toolbarTopFixedTitle; String? toolbarTopFixedTitle;
///Set to `false` to not close the InAppBrowser when the user click on the Android back button and the WebView cannot go back to the history. The default value is `true`. ///Set to `false` to not close the InAppBrowser when the user click on the Android back button and the WebView cannot go back to the history. The default value is `true`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [AndroidPlatform()])
AndroidPlatform()
])
bool? closeOnCannotGoBack; bool? closeOnCannotGoBack;
///Set to `false` to block the InAppBrowser WebView going back when the user click on the Android back button. The default value is `true`. ///Set to `false` to block the InAppBrowser WebView going back when the user click on the Android back button. The default value is `true`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [AndroidPlatform()])
AndroidPlatform()
])
bool? allowGoBackWithBackButton; bool? allowGoBackWithBackButton;
///Set to `true` to close the InAppBrowser when the user click on the Android back button. The default value is `false`. ///Set to `true` to close the InAppBrowser when the user click on the Android back button. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [AndroidPlatform()])
AndroidPlatform()
])
bool? shouldCloseOnBackButtonPressed; bool? shouldCloseOnBackButtonPressed;
///Set to `true` to set the toolbar at the top translucent. The default value is `true`. ///Set to `true` to set the toolbar at the top translucent. The default value is `true`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
bool? toolbarTopTranslucent; bool? toolbarTopTranslucent;
///Set the tint color to apply to the navigation bar background. ///Set the tint color to apply to the navigation bar background.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
Color_? toolbarTopBarTintColor; Color_? toolbarTopBarTintColor;
///Set the tint color to apply to the navigation items and bar button items. ///Set the tint color to apply to the navigation items and bar button items.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
Color_? toolbarTopTintColor; Color_? toolbarTopTintColor;
///Set to `true` to hide the toolbar at the bottom of the WebView. The default value is `false`. ///Set to `true` to hide the toolbar at the bottom of the WebView. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
bool? hideToolbarBottom; bool? hideToolbarBottom;
///Set the custom background color of the toolbar at the bottom. ///Set the custom background color of the toolbar at the bottom.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
Color_? toolbarBottomBackgroundColor; Color_? toolbarBottomBackgroundColor;
///Set the tint color to apply to the bar button items. ///Set the tint color to apply to the bar button items.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
Color_? toolbarBottomTintColor; Color_? toolbarBottomTintColor;
///Set to `true` to set the toolbar at the bottom translucent. The default value is `true`. ///Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
bool? toolbarBottomTranslucent; bool? toolbarBottomTranslucent;
///Set the custom text for the close button. ///Set the custom text for the close button.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
String? closeButtonCaption; String? closeButtonCaption;
///Set the custom color for the close button. ///Set the custom color for the close button.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
Color_? closeButtonColor; Color_? closeButtonColor;
///Set to `true` to hide the close button. The default value is `false`. ///Set to `true` to hide the close button. The default value is `false`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
bool? hideCloseButton; bool? hideCloseButton;
///Set the custom color for the menu button. ///Set the custom color for the menu button.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
Color_? menuButtonColor; Color_? menuButtonColor;
///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN]. ///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN].
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
ModalPresentationStyle_? presentationStyle; ModalPresentationStyle_? presentationStyle;
///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL]. ///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL].
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [IOSPlatform()])
IOSPlatform()
])
ModalTransitionStyle_? transitionStyle; ModalTransitionStyle_? transitionStyle;
///How the browser window should be added to the main window. ///How the browser window should be added to the main window.
///The default value is [WindowType.WINDOW]. ///The default value is [WindowType.WINDOW].
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [MacOSPlatform(), WindowsPlatform()])
MacOSPlatform(),
WindowsPlatform()
])
WindowType_? windowType; WindowType_? windowType;
///The windows alpha value. ///The windows alpha value.
///The default value is `1.0`. ///The default value is `1.0`.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [MacOSPlatform(), WindowsPlatform()])
MacOSPlatform(),
WindowsPlatform()
])
double? windowAlphaValue; double? windowAlphaValue;
///Flags that describe the windows current style, such as if its resizable or in full-screen mode. ///Flags that describe the windows current style, such as if its resizable or in full-screen mode.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [MacOSPlatform()])
MacOSPlatform()
])
WindowStyleMask_? windowStyleMask; WindowStyleMask_? windowStyleMask;
///The type of separator that the app displays between the title bar and content of a window. ///The type of separator that the app displays between the title bar and content of a window.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [MacOSPlatform(available: '11.0')])
MacOSPlatform(available: '11.0')
])
WindowTitlebarSeparatorStyle_? windowTitlebarSeparatorStyle; WindowTitlebarSeparatorStyle_? windowTitlebarSeparatorStyle;
///Sets the origin and size of the windows frame rectangle according to a given frame rectangle, ///Sets the origin and size of the windows frame rectangle according to a given frame rectangle,
///thereby setting its position and size onscreen. ///thereby setting its position and size onscreen.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [MacOSPlatform(), WindowsPlatform()])
MacOSPlatform(),
WindowsPlatform()
])
InAppWebViewRect_? windowFrame; InAppWebViewRect_? windowFrame;
InAppBrowserSettings_( InAppBrowserSettings_(

View File

@ -40,6 +40,7 @@ class InAppBrowserSettings
///- Android native WebView ///- Android native WebView
///- iOS ///- iOS
///- MacOS ///- MacOS
///- Windows
bool? hidden; bool? hidden;
///Set to `true` to hide the close button. The default value is `false`. ///Set to `true` to hide the close button. The default value is `false`.
@ -53,6 +54,7 @@ class InAppBrowserSettings
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- Android native WebView ///- Android native WebView
///- iOS ///- iOS
///- MacOS
bool? hideDefaultMenuItems; bool? hideDefaultMenuItems;
///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`. ///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`.
@ -146,6 +148,7 @@ class InAppBrowserSettings
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- Android native WebView ///- Android native WebView
///- MacOS ///- MacOS
///- Windows
String? toolbarTopFixedTitle; String? toolbarTopFixedTitle;
///Set the tint color to apply to the navigation items and bar button items. ///Set the tint color to apply to the navigation items and bar button items.
@ -171,6 +174,7 @@ class InAppBrowserSettings
/// ///
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- MacOS ///- MacOS
///- Windows
double? windowAlphaValue; double? windowAlphaValue;
///Sets the origin and size of the windows frame rectangle according to a given frame rectangle, ///Sets the origin and size of the windows frame rectangle according to a given frame rectangle,
@ -178,6 +182,7 @@ class InAppBrowserSettings
/// ///
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- MacOS ///- MacOS
///- Windows
InAppWebViewRect? windowFrame; InAppWebViewRect? windowFrame;
///Flags that describe the windows current style, such as if its resizable or in full-screen mode. ///Flags that describe the windows current style, such as if its resizable or in full-screen mode.
@ -188,10 +193,8 @@ class InAppBrowserSettings
///The type of separator that the app displays between the title bar and content of a window. ///The type of separator that the app displays between the title bar and content of a window.
/// ///
///**NOTE for MacOS**: available on MacOS 11.0+.
///
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- MacOS ///- MacOS 11.0+
WindowTitlebarSeparatorStyle? windowTitlebarSeparatorStyle; WindowTitlebarSeparatorStyle? windowTitlebarSeparatorStyle;
///How the browser window should be added to the main window. ///How the browser window should be added to the main window.
@ -199,6 +202,7 @@ class InAppBrowserSettings
/// ///
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- MacOS ///- MacOS
///- Windows
WindowType? windowType; WindowType? windowType;
InAppBrowserSettings( InAppBrowserSettings(
{this.allowGoBackWithBackButton = true, {this.allowGoBackWithBackButton = true,

View File

@ -32,8 +32,8 @@ import '../pull_to_refresh/platform_pull_to_refresh_controller.dart';
@immutable @immutable
class PlatformInAppBrowserCreationParams { class PlatformInAppBrowserCreationParams {
/// Used by the platform implementation to create a new [PlatformInAppBrowser]. /// Used by the platform implementation to create a new [PlatformInAppBrowser].
const PlatformInAppBrowserCreationParams( const PlatformInAppBrowserCreationParams({
{this.contextMenu, this.contextMenu,
this.pullToRefreshController, this.pullToRefreshController,
this.findInteractionController, this.findInteractionController,
this.initialUserScripts, this.initialUserScripts,

View File

@ -37,6 +37,5 @@ class InAppWebViewControllerKeepAliveProps {
this.injectedScriptsFromURL = const {}, this.injectedScriptsFromURL = const {},
this.webMessageChannels = const {}, this.webMessageChannels = const {},
this.webMessageListeners = const {}, this.webMessageListeners = const {},
this.devToolsProtocolEventListenerMap = const {} this.devToolsProtocolEventListenerMap = const {}});
});
} }

View File

@ -57,8 +57,12 @@ class InAppWebViewSettings_ {
///If the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event is implemented and this value is `null`, ///If the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event is implemented and this value is `null`,
///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///it will be automatically inferred as `true`, otherwise, the default value is `false`.
///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually.
@SupportedPlatforms( @SupportedPlatforms(platforms: [
platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform(), WindowsPlatform()]) AndroidPlatform(),
IOSPlatform(),
MacOSPlatform(),
WindowsPlatform()
])
bool? useShouldOverrideUrlLoading; bool? useShouldOverrideUrlLoading;
///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onLoadResource] event. ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onLoadResource] event.
@ -101,8 +105,8 @@ class InAppWebViewSettings_ {
"https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent"), "https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent"),
WindowsPlatform( WindowsPlatform(
apiName: 'ICoreWebView2Settings2.put_UserAgent', apiName: 'ICoreWebView2Settings2.put_UserAgent',
apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings2?view=webview2-1.0.2210.55#put_useragent' apiUrl:
) 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings2?view=webview2-1.0.2210.55#put_useragent')
]) ])
String? userAgent; String? userAgent;
@ -138,8 +142,7 @@ class InAppWebViewSettings_ {
WindowsPlatform( WindowsPlatform(
apiName: "ICoreWebView2Settings.put_IsScriptEnabled", apiName: "ICoreWebView2Settings.put_IsScriptEnabled",
apiUrl: apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_isscriptenabled" "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_isscriptenabled")
)
]) ])
bool? javaScriptEnabled; bool? javaScriptEnabled;
@ -320,8 +323,8 @@ because there isn't any way to make the website data store non-persistent for th
WindowsPlatform( WindowsPlatform(
available: '1.0.774.44', available: '1.0.774.44',
apiName: 'ICoreWebView2Controller2.put_DefaultBackgroundColor', apiName: 'ICoreWebView2Controller2.put_DefaultBackgroundColor',
apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller2?view=webview2-1.0.2210.55#put_defaultbackgroundcolor' apiUrl:
) 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller2?view=webview2-1.0.2210.55#put_defaultbackgroundcolor')
]) ])
bool? transparentBackground; bool? transparentBackground;
@ -336,13 +339,14 @@ because there isn't any way to make the website data store non-persistent for th
bool? disableHorizontalScroll; bool? disableHorizontalScroll;
///Set to `true` to disable context menu. The default value is `false`. ///Set to `true` to disable context menu. The default value is `false`.
@SupportedPlatforms( @SupportedPlatforms(platforms: [
platforms: [AndroidPlatform(), IOSPlatform(), WebPlatform(), AndroidPlatform(),
IOSPlatform(),
WebPlatform(),
WindowsPlatform( WindowsPlatform(
apiName: "ICoreWebView2Settings.put_AreDefaultContextMenusEnabled", apiName: "ICoreWebView2Settings.put_AreDefaultContextMenusEnabled",
apiUrl: apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredefaultcontextmenusenabled" "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredefaultcontextmenusenabled")
)
]) ])
bool? disableContextMenu; bool? disableContextMenu;
@ -357,8 +361,7 @@ because there isn't any way to make the website data store non-persistent for th
WindowsPlatform( WindowsPlatform(
apiName: "ICoreWebView2Settings.put_IsZoomControlEnabled", apiName: "ICoreWebView2Settings.put_IsZoomControlEnabled",
apiUrl: apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_iszoomcontrolenabled" "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_iszoomcontrolenabled")
)
]) ])
bool? supportZoom; bool? supportZoom;
@ -1566,8 +1569,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri
WindowsPlatform( WindowsPlatform(
apiName: "ICoreWebView2Settings.put_AreDevToolsEnabled", apiName: "ICoreWebView2Settings.put_AreDevToolsEnabled",
apiUrl: apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredevtoolsenabled" "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredevtoolsenabled")
)
]) ])
bool? isInspectable; bool? isInspectable;

View File

@ -2069,7 +2069,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2.CallDevToolsProtocolMethod](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#calldevtoolsprotocolmethod)) ///- Windows ([Official API - ICoreWebView2.CallDevToolsProtocolMethod](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#calldevtoolsprotocolmethod))
///{@endtemplate} ///{@endtemplate}
Future<dynamic> callDevToolsProtocolMethod({required String methodName, Map<String, dynamic>? parameters}) { Future<dynamic> callDevToolsProtocolMethod(
{required String methodName, Map<String, dynamic>? parameters}) {
throw UnimplementedError( throw UnimplementedError(
'callDevToolsProtocolMethod is not implemented on the current platform'); 'callDevToolsProtocolMethod is not implemented on the current platform');
} }
@ -2080,7 +2081,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2DevToolsProtocolEventReceiver.add_DevToolsProtocolEventReceived](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#add_devtoolsprotocoleventreceived)) ///- Windows ([Official API - ICoreWebView2DevToolsProtocolEventReceiver.add_DevToolsProtocolEventReceived](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#add_devtoolsprotocoleventreceived))
///{@endtemplate} ///{@endtemplate}
Future<void> addDevToolsProtocolEventListener({required String eventName, required Function(dynamic data) callback}) { Future<void> addDevToolsProtocolEventListener(
{required String eventName, required Function(dynamic data) callback}) {
throw UnimplementedError( throw UnimplementedError(
'addDevToolsProtocolEventListener is not implemented on the current platform'); 'addDevToolsProtocolEventListener is not implemented on the current platform');
} }
@ -2091,7 +2093,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2DevToolsProtocolEventReceiver.remove_DevToolsProtocolEventReceived](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#remove_devtoolsprotocoleventreceived)) ///- Windows ([Official API - ICoreWebView2DevToolsProtocolEventReceiver.remove_DevToolsProtocolEventReceived](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#remove_devtoolsprotocoleventreceived))
///{@endtemplate} ///{@endtemplate}
Future<void> removeDevToolsProtocolEventListener({required String eventName}) { Future<void> removeDevToolsProtocolEventListener(
{required String eventName}) {
throw UnimplementedError( throw UnimplementedError(
'removeDevToolsProtocolEventListener is not implemented on the current platform'); 'removeDevToolsProtocolEventListener is not implemented on the current platform');
} }

View File

@ -41,11 +41,8 @@ class Cookie_ {
int? expiresDate; int? expiresDate;
///Indicates if the cookie is a session only cookie. ///Indicates if the cookie is a session only cookie.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
IOSPlatform(), platforms: [IOSPlatform(), MacOSPlatform(), WindowsPlatform()])
MacOSPlatform(),
WindowsPlatform()
])
bool? isSessionOnly; bool? isSessionOnly;
///The cookie domain. ///The cookie domain.

View File

@ -25,11 +25,10 @@ class NavigationType_ {
apiUrl: apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated', 'https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated',
value: 0), value: 0),
EnumWindowsPlatform( EnumWindowsPlatform(value: 0),
value: 0
),
]) ])
static const LINK_ACTIVATED = const NavigationType_._internal('LINK_ACTIVATED'); static const LINK_ACTIVATED =
const NavigationType_._internal('LINK_ACTIVATED');
///A form was submitted. ///A form was submitted.
@EnumSupportedPlatforms(platforms: [ @EnumSupportedPlatforms(platforms: [
@ -44,7 +43,8 @@ class NavigationType_ {
'https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted', 'https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted',
value: 1), value: 1),
]) ])
static const FORM_SUBMITTED = const NavigationType_._internal('FORM_SUBMITTED'); static const FORM_SUBMITTED =
const NavigationType_._internal('FORM_SUBMITTED');
///An item from the back-forward list was requested. ///An item from the back-forward list was requested.
@EnumSupportedPlatforms(platforms: [ @EnumSupportedPlatforms(platforms: [
@ -62,8 +62,7 @@ class NavigationType_ {
apiName: 'COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD', apiName: 'COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD',
apiUrl: apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind',
value: 1 value: 1),
),
]) ])
static const BACK_FORWARD = const NavigationType_._internal('BACK_FORWARD'); static const BACK_FORWARD = const NavigationType_._internal('BACK_FORWARD');
@ -83,8 +82,7 @@ class NavigationType_ {
apiName: 'COREWEBVIEW2_NAVIGATION_KIND_RELOAD', apiName: 'COREWEBVIEW2_NAVIGATION_KIND_RELOAD',
apiUrl: apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind',
value: 2 value: 2),
),
]) ])
static const RELOAD = const NavigationType_._internal('RELOAD'); static const RELOAD = const NavigationType_._internal('RELOAD');
@ -101,7 +99,8 @@ class NavigationType_ {
'https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted', 'https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted',
value: 4), value: 4),
]) ])
static const FORM_RESUBMITTED = const NavigationType_._internal('FORM_RESUBMITTED'); static const FORM_RESUBMITTED =
const NavigationType_._internal('FORM_RESUBMITTED');
///Navigation is taking place for some other reason. ///Navigation is taking place for some other reason.
@EnumSupportedPlatforms(platforms: [ @EnumSupportedPlatforms(platforms: [
@ -115,9 +114,7 @@ class NavigationType_ {
apiUrl: apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/other', 'https://developer.apple.com/documentation/webkit/wknavigationtype/other',
value: -1), value: -1),
EnumWindowsPlatform( EnumWindowsPlatform(value: 3),
value: 3
),
]) ])
static const OTHER = const NavigationType_._internal('OTHER'); static const OTHER = const NavigationType_._internal('OTHER');
} }

View File

@ -25,11 +25,8 @@ class ScreenshotConfiguration_ {
///The web view maintains the aspect ratio of the captured content, but scales it to match the width you specify. ///The web view maintains the aspect ratio of the captured content, but scales it to match the width you specify.
/// ///
///The default value of this property is `null`, which returns an image whose size matches the original size of the captured rectangle. ///The default value of this property is `null`, which returns an image whose size matches the original size of the captured rectangle.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(
AndroidPlatform(), platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
IOSPlatform(),
MacOSPlatform()
])
double? snapshotWidth; double? snapshotWidth;
///The compression format of the captured image. ///The compression format of the captured image.

View File

@ -25,11 +25,14 @@ class WebHistoryItem_ {
int? offset; int? offset;
///Unique id of the navigation history entry. ///Unique id of the navigation history entry.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [WindowsPlatform()])
WindowsPlatform()
])
int? entryId; int? entryId;
WebHistoryItem_( WebHistoryItem_(
{this.originalUrl, this.title, this.url, this.index, this.offset, this.entryId}); {this.originalUrl,
this.title,
this.url,
this.index,
this.offset,
this.entryId});
} }

View File

@ -388,7 +388,8 @@ class WebResourceErrorType_ {
'https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse', 'https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse',
value: -1011), value: -1011),
EnumWindowsPlatform( EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE', apiName:
'COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE',
apiUrl: apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 8) value: 8)
@ -426,7 +427,8 @@ class WebResourceErrorType_ {
'https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired', 'https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired',
value: -1013), value: -1013),
EnumWindowsPlatform( EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED', apiName:
'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED',
apiUrl: apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 17), value: 17),
@ -941,7 +943,8 @@ class WebResourceErrorType_ {
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 6), value: 6),
]) ])
static const SERVER_UNREACHABLE = WebResourceErrorType_._internal("SERVER_UNREACHABLE"); static const SERVER_UNREACHABLE =
WebResourceErrorType_._internal("SERVER_UNREACHABLE");
///Indicates that the connection was stopped. ///Indicates that the connection was stopped.
@EnumSupportedPlatforms(platforms: [ @EnumSupportedPlatforms(platforms: [
@ -951,7 +954,8 @@ class WebResourceErrorType_ {
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 9) value: 9)
]) ])
static const CONNECTION_ABORTED = WebResourceErrorType_._internal("CONNECTION_ABORTED"); static const CONNECTION_ABORTED =
WebResourceErrorType_._internal("CONNECTION_ABORTED");
///Indicates that the connection was reset. ///Indicates that the connection was reset.
@EnumSupportedPlatforms(platforms: [ @EnumSupportedPlatforms(platforms: [
@ -971,7 +975,8 @@ class WebResourceErrorType_ {
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 15), value: 15),
]) ])
static const REDIRECT_FAILED = WebResourceErrorType_._internal("REDIRECT_FAILED"); static const REDIRECT_FAILED =
WebResourceErrorType_._internal("REDIRECT_FAILED");
///Indicates that an unexpected error occurred. ///Indicates that an unexpected error occurred.
@EnumSupportedPlatforms(platforms: [ @EnumSupportedPlatforms(platforms: [
@ -981,15 +986,18 @@ class WebResourceErrorType_ {
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 16), value: 16),
]) ])
static const UNEXPECTED_ERROR = WebResourceErrorType_._internal("UNEXPECTED_ERROR"); static const UNEXPECTED_ERROR =
WebResourceErrorType_._internal("UNEXPECTED_ERROR");
///Indicates that user lacks proper authentication credentials for a proxy server. ///Indicates that user lacks proper authentication credentials for a proxy server.
@EnumSupportedPlatforms(platforms: [ @EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform( EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED', apiName:
'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED',
apiUrl: apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status', 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 18), value: 18),
]) ])
static const VALID_PROXY_AUTHENTICATION_REQUIRED = WebResourceErrorType_._internal("VALID_PROXY_AUTHENTICATION_REQUIRED"); static const VALID_PROXY_AUTHENTICATION_REQUIRED =
WebResourceErrorType_._internal("VALID_PROXY_AUTHENTICATION_REQUIRED");
} }

View File

@ -12,11 +12,17 @@ class WindowType_ {
const WindowType_._internal(this._value); const WindowType_._internal(this._value);
///Adds the new browser window as a separate new window from the main window. ///Adds the new browser window as a separate new window from the main window.
@EnumSupportedPlatforms(platforms: [EnumMacOSPlatform(value: 'WINDOW'), EnumWindowsPlatform(value: 'WINDOW')]) @EnumSupportedPlatforms(platforms: [
EnumMacOSPlatform(value: 'WINDOW'),
EnumWindowsPlatform(value: 'WINDOW')
])
static const WINDOW = const WindowType_._internal('WINDOW'); static const WINDOW = const WindowType_._internal('WINDOW');
///Adds the new browser window as a child window of the main window. ///Adds the new browser window as a child window of the main window.
@EnumSupportedPlatforms(platforms: [EnumMacOSPlatform(value: 'CHILD'), EnumWindowsPlatform(value: 'CHILD')]) @EnumSupportedPlatforms(platforms: [
EnumMacOSPlatform(value: 'CHILD'),
EnumWindowsPlatform(value: 'CHILD')
])
static const CHILD = const WindowType_._internal('CHILD'); static const CHILD = const WindowType_._internal('CHILD');
///Adds the new browser window as a new tab in a tabbed window of the main window. ///Adds the new browser window as a new tab in a tabbed window of the main window.

View File

@ -27,9 +27,8 @@ class PlatformWebViewEnvironmentCreationParams {
abstract class PlatformWebViewEnvironment extends PlatformInterface abstract class PlatformWebViewEnvironment extends PlatformInterface
implements Disposable { implements Disposable {
///Debug settings used by [PlatformWebViewEnvironment]. ///Debug settings used by [PlatformWebViewEnvironment].
static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings( static DebugLoggingSettings debugLoggingSettings =
maxLogMessageLength: 1000 DebugLoggingSettings(maxLogMessageLength: 1000);
);
/// Creates a new [PlatformInAppWebViewController] /// Creates a new [PlatformInAppWebViewController]
factory PlatformWebViewEnvironment( factory PlatformWebViewEnvironment(
@ -42,8 +41,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
'`InAppWebViewPlatform.instance` can be set with your own test implementation.', '`InAppWebViewPlatform.instance` can be set with your own test implementation.',
); );
final PlatformWebViewEnvironment webViewEnvironment = final PlatformWebViewEnvironment webViewEnvironment =
InAppWebViewPlatform.instance! InAppWebViewPlatform.instance!.createPlatformWebViewEnvironment(params);
.createPlatformWebViewEnvironment(params);
PlatformInterface.verify(webViewEnvironment, _token); PlatformInterface.verify(webViewEnvironment, _token);
return webViewEnvironment; return webViewEnvironment;
} }
@ -58,8 +56,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
'`InAppWebViewPlatform.instance` can be set with your own test implementation.', '`InAppWebViewPlatform.instance` can be set with your own test implementation.',
); );
final PlatformWebViewEnvironment webViewEnvironment = final PlatformWebViewEnvironment webViewEnvironment =
InAppWebViewPlatform.instance! InAppWebViewPlatform.instance!.createPlatformWebViewEnvironmentStatic();
.createPlatformWebViewEnvironmentStatic();
PlatformInterface.verify(webViewEnvironment, _token); PlatformInterface.verify(webViewEnvironment, _token);
return webViewEnvironment; return webViewEnvironment;
} }
@ -69,8 +66,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
/// Should only be used by platform implementations because they can't extend /// Should only be used by platform implementations because they can't extend
/// a class that only contains a factory constructor. /// a class that only contains a factory constructor.
@protected @protected
PlatformWebViewEnvironment.implementation(this.params) PlatformWebViewEnvironment.implementation(this.params) : super(token: _token);
: super(token: _token);
static final Object _token = Object(); static final Object _token = Object();
@ -114,8 +110,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
///**Officially Supported Platforms/Implementations**: ///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - GetAvailableCoreWebView2BrowserVersionString](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions)) ///- Windows ([Official API - GetAvailableCoreWebView2BrowserVersionString](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions))
///{@endtemplate} ///{@endtemplate}
Future<String?> getAvailableVersion( Future<String?> getAvailableVersion({String? browserExecutableFolder}) {
{String? browserExecutableFolder}) {
throw UnimplementedError( throw UnimplementedError(
'getAvailableVersion is not implemented on the current platform'); 'getAvailableVersion is not implemented on the current platform');
} }

View File

@ -8,9 +8,7 @@ part 'webview_environment_settings.g.dart';
/// ///
///The [browserExecutableFolder], [userDataFolder] and [additionalBrowserArguments] ///The [browserExecutableFolder], [userDataFolder] and [additionalBrowserArguments]
///may be overridden by values either specified in environment variables or in the registry. ///may be overridden by values either specified in environment variables or in the registry.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [WindowsPlatform()])
WindowsPlatform()
])
@ExchangeableObject(copyMethod: true) @ExchangeableObject(copyMethod: true)
class WebViewEnvironmentSettings_ { class WebViewEnvironmentSettings_ {
///Use [browserExecutableFolder] to specify whether WebView2 controls use a fixed ///Use [browserExecutableFolder] to specify whether WebView2 controls use a fixed
@ -29,7 +27,11 @@ class WebViewEnvironmentSettings_ {
///When an override `WEBVIEW2_RELEASE_CHANNEL_PREFERENCE` environment variable or ///When an override `WEBVIEW2_RELEASE_CHANNEL_PREFERENCE` environment variable or
///applicable `releaseChannelPreference` registry value is set to `1`, the channel search order is reversed. ///applicable `releaseChannelPreference` registry value is set to `1`, the channel search order is reversed.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'CreateCoreWebView2EnvironmentWithOptions.browserExecutableFolder', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions') WindowsPlatform(
apiName:
'CreateCoreWebView2EnvironmentWithOptions.browserExecutableFolder',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions')
]) ])
final String? browserExecutableFolder; final String? browserExecutableFolder;
@ -48,7 +50,10 @@ class WebViewEnvironmentSettings_ {
///options does not match the options of the WebViews that are currently ///options does not match the options of the WebViews that are currently
///running in the shared browser process. ///running in the shared browser process.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'CreateCoreWebView2EnvironmentWithOptions.userDataFolder', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions') WindowsPlatform(
apiName: 'CreateCoreWebView2EnvironmentWithOptions.userDataFolder',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions')
]) ])
final String? userDataFolder; final String? userDataFolder;
@ -57,35 +62,49 @@ class WebViewEnvironmentSettings_ {
///in which case the features should be comma-seperated. ///in which case the features should be comma-seperated.
///Example: `"--disable-features=feature1,feature2 --some-other-switch --do-something"` ///Example: `"--disable-features=feature1,feature2 --some-other-switch --do-something"`
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_AdditionalBrowserArguments', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_additionalbrowserarguments') WindowsPlatform(
apiName:
'ICoreWebView2EnvironmentOptions.put_AdditionalBrowserArguments',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_additionalbrowserarguments')
]) ])
final String? additionalBrowserArguments; final String? additionalBrowserArguments;
///This property is used to enable single sign on with Azure Active Directory (AAD) ///This property is used to enable single sign on with Azure Active Directory (AAD)
///and personal Microsoft Account (MSA) resources inside WebView. ///and personal Microsoft Account (MSA) resources inside WebView.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_AllowSingleSignOnUsingOSPrimaryAccount', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_allowsinglesignonusingosprimaryaccount') WindowsPlatform(
apiName:
'ICoreWebView2EnvironmentOptions.put_AllowSingleSignOnUsingOSPrimaryAccount',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_allowsinglesignonusingosprimaryaccount')
]) ])
final bool? allowSingleSignOnUsingOSPrimaryAccount; final bool? allowSingleSignOnUsingOSPrimaryAccount;
///The default display language for WebView. ///The default display language for WebView.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_Language', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_language') WindowsPlatform(
apiName: 'ICoreWebView2EnvironmentOptions.put_Language',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_language')
]) ])
final String? language; final String? language;
///Specifies the version of the WebView2 Runtime binaries required to be compatible with your app. ///Specifies the version of the WebView2 Runtime binaries required to be compatible with your app.
@SupportedPlatforms(platforms: [ @SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_TargetCompatibleBrowserVersion', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_targetcompatiblebrowserversion') WindowsPlatform(
apiName:
'ICoreWebView2EnvironmentOptions.put_TargetCompatibleBrowserVersion',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_targetcompatiblebrowserversion')
]) ])
final String? targetCompatibleBrowserVersion; final String? targetCompatibleBrowserVersion;
WebViewEnvironmentSettings_({ WebViewEnvironmentSettings_(
this.browserExecutableFolder, {this.browserExecutableFolder,
this.userDataFolder, this.userDataFolder,
this.additionalBrowserArguments, this.additionalBrowserArguments,
this.allowSingleSignOnUsingOSPrimaryAccount, this.allowSingleSignOnUsingOSPrimaryAccount,
this.language, this.language,
this.targetCompatibleBrowserVersion this.targetCompatibleBrowserVersion});
});
} }

View File

@ -16,8 +16,7 @@ import 'webview_environment/webview_environment.dart';
class WindowsCookieManagerCreationParams class WindowsCookieManagerCreationParams
extends PlatformCookieManagerCreationParams { extends PlatformCookieManagerCreationParams {
/// Creates a new [WindowsCookieManagerCreationParams] instance. /// Creates a new [WindowsCookieManagerCreationParams] instance.
const WindowsCookieManagerCreationParams( const WindowsCookieManagerCreationParams({this.webViewEnvironment});
{this.webViewEnvironment});
/// Creates a [WindowsCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams]. /// Creates a [WindowsCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams].
factory WindowsCookieManagerCreationParams.fromPlatformCookieManagerCreationParams( factory WindowsCookieManagerCreationParams.fromPlatformCookieManagerCreationParams(
@ -25,7 +24,8 @@ class WindowsCookieManagerCreationParams
// ignore: avoid_unused_constructor_parameters // ignore: avoid_unused_constructor_parameters
PlatformCookieManagerCreationParams params) { PlatformCookieManagerCreationParams params) {
return WindowsCookieManagerCreationParams( return WindowsCookieManagerCreationParams(
webViewEnvironment: params.webViewEnvironment as WindowsWebViewEnvironment?); webViewEnvironment:
params.webViewEnvironment as WindowsWebViewEnvironment?);
} }
@override @override
@ -52,16 +52,16 @@ class WindowsCookieManager extends PlatformCookieManager
static WindowsCookieManager? _instance; static WindowsCookieManager? _instance;
///Gets the [WindowsCookieManager] shared instance. ///Gets the [WindowsCookieManager] shared instance.
static WindowsCookieManager instance({WindowsWebViewEnvironment? webViewEnvironment}) { static WindowsCookieManager instance(
{WindowsWebViewEnvironment? webViewEnvironment}) {
if (webViewEnvironment == null) { if (webViewEnvironment == null) {
if (_instance == null) { if (_instance == null) {
_instance = _init(); _instance = _init();
} }
return _instance!; return _instance!;
} else { } else {
return WindowsCookieManager( return WindowsCookieManager(WindowsCookieManagerCreationParams(
WindowsCookieManagerCreationParams(webViewEnvironment: webViewEnvironment) webViewEnvironment: webViewEnvironment));
);
} }
} }
@ -103,7 +103,8 @@ class WindowsCookieManager extends PlatformCookieManager
args.putIfAbsent('isSecure', () => isSecure); args.putIfAbsent('isSecure', () => isSecure);
args.putIfAbsent('isHttpOnly', () => isHttpOnly); args.putIfAbsent('isHttpOnly', () => isHttpOnly);
args.putIfAbsent('sameSite', () => sameSite?.toNativeValue()); args.putIfAbsent('sameSite', () => sameSite?.toNativeValue());
args.putIfAbsent('webViewEnvironmentId', () => params.webViewEnvironment?.id); args.putIfAbsent(
'webViewEnvironmentId', () => params.webViewEnvironment?.id);
return await channel?.invokeMethod<bool>('setCookie', args) ?? false; return await channel?.invokeMethod<bool>('setCookie', args) ?? false;
} }
@ -120,7 +121,8 @@ class WindowsCookieManager extends PlatformCookieManager
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('url', () => url.toString());
args.putIfAbsent('webViewEnvironmentId', () => params.webViewEnvironment?.id); args.putIfAbsent(
'webViewEnvironmentId', () => params.webViewEnvironment?.id);
List<dynamic> cookieListMap = List<dynamic> cookieListMap =
await channel?.invokeMethod<List>('getCookies', args) ?? []; await channel?.invokeMethod<List>('getCookies', args) ?? [];
cookieListMap = cookieListMap.cast<Map<dynamic, dynamic>>(); cookieListMap = cookieListMap.cast<Map<dynamic, dynamic>>();
@ -153,7 +155,8 @@ class WindowsCookieManager extends PlatformCookieManager
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('url', () => url.toString());
args.putIfAbsent('webViewEnvironmentId', () => params.webViewEnvironment?.id); args.putIfAbsent(
'webViewEnvironmentId', () => params.webViewEnvironment?.id);
List<dynamic> cookies = List<dynamic> cookies =
await channel?.invokeMethod<List>('getCookies', args) ?? []; await channel?.invokeMethod<List>('getCookies', args) ?? [];
cookies = cookies.cast<Map<dynamic, dynamic>>(); cookies = cookies.cast<Map<dynamic, dynamic>>();
@ -192,7 +195,8 @@ class WindowsCookieManager extends PlatformCookieManager
args.putIfAbsent('name', () => name); args.putIfAbsent('name', () => name);
args.putIfAbsent('domain', () => domain); args.putIfAbsent('domain', () => domain);
args.putIfAbsent('path', () => path); args.putIfAbsent('path', () => path);
args.putIfAbsent('webViewEnvironmentId', () => params.webViewEnvironment?.id); args.putIfAbsent(
'webViewEnvironmentId', () => params.webViewEnvironment?.id);
return await channel?.invokeMethod<bool>('deleteCookie', args) ?? false; return await channel?.invokeMethod<bool>('deleteCookie', args) ?? false;
} }
@ -210,14 +214,16 @@ class WindowsCookieManager extends PlatformCookieManager
args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('url', () => url.toString());
args.putIfAbsent('domain', () => domain); args.putIfAbsent('domain', () => domain);
args.putIfAbsent('path', () => path); args.putIfAbsent('path', () => path);
args.putIfAbsent('webViewEnvironmentId', () => params.webViewEnvironment?.id); args.putIfAbsent(
'webViewEnvironmentId', () => params.webViewEnvironment?.id);
return await channel?.invokeMethod<bool>('deleteCookies', args) ?? false; return await channel?.invokeMethod<bool>('deleteCookies', args) ?? false;
} }
@override @override
Future<bool> deleteAllCookies() async { Future<bool> deleteAllCookies() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('webViewEnvironmentId', () => params.webViewEnvironment?.id); args.putIfAbsent(
'webViewEnvironmentId', () => params.webViewEnvironment?.id);
return await channel?.invokeMethod<bool>('deleteAllCookies', args) ?? false; return await channel?.invokeMethod<bool>('deleteAllCookies', args) ?? false;
} }

View File

@ -114,7 +114,8 @@ class WindowsFindInteractionController extends PlatformFindInteractionController
} }
} }
extension InternalFindInteractionController on WindowsFindInteractionController { extension InternalFindInteractionController
on WindowsFindInteractionController {
void init(dynamic id) { void init(dynamic id) {
channel = MethodChannel( channel = MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_find_interaction_$id'); 'com.pichillilorenzo/flutter_inappwebview_find_interaction_$id');

View File

@ -26,8 +26,8 @@ class WindowsHttpAuthCredentialDatabaseCreationParams
} }
///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase} ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase}
class WindowsHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase class WindowsHttpAuthCredentialDatabase
with ChannelController { extends PlatformHttpAuthCredentialDatabase with ChannelController {
/// Creates a new [WindowsHttpAuthCredentialDatabase]. /// Creates a new [WindowsHttpAuthCredentialDatabase].
WindowsHttpAuthCredentialDatabase( WindowsHttpAuthCredentialDatabase(
PlatformHttpAuthCredentialDatabaseCreationParams params) PlatformHttpAuthCredentialDatabaseCreationParams params)

View File

@ -33,11 +33,12 @@ class WindowsInAppBrowserCreationParams
return WindowsInAppBrowserCreationParams( return WindowsInAppBrowserCreationParams(
contextMenu: params.contextMenu, contextMenu: params.contextMenu,
pullToRefreshController: params.pullToRefreshController, pullToRefreshController: params.pullToRefreshController,
findInteractionController: findInteractionController: params.findInteractionController
params.findInteractionController as WindowsFindInteractionController?, as WindowsFindInteractionController?,
initialUserScripts: params.initialUserScripts, initialUserScripts: params.initialUserScripts,
windowId: params.windowId, windowId: params.windowId,
webViewEnvironment: params.webViewEnvironment as WindowsWebViewEnvironment?); webViewEnvironment:
params.webViewEnvironment as WindowsWebViewEnvironment?);
} }
@override @override
@ -174,7 +175,8 @@ class WindowsInAppBrowser extends PlatformInAppBrowser with ChannelController {
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings); args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
args.putIfAbsent('menuItems', () => menuItemList); args.putIfAbsent('menuItems', () => menuItemList);
args.putIfAbsent('webViewEnvironmentId', () => _windowsParams.webViewEnvironment?.id); args.putIfAbsent(
'webViewEnvironmentId', () => _windowsParams.webViewEnvironment?.id);
return args; return args;
} }

View File

@ -128,8 +128,8 @@ class CustomPlatformViewController
_methodChannel = _methodChannel =
MethodChannel('com.pichillilorenzo/custom_platform_view_$_textureId'); MethodChannel('com.pichillilorenzo/custom_platform_view_$_textureId');
_eventChannel = _eventChannel = EventChannel(
EventChannel('com.pichillilorenzo/custom_platform_view_${_textureId}_events'); 'com.pichillilorenzo/custom_platform_view_${_textureId}_events');
_eventStreamSubscription = _eventStreamSubscription =
_eventChannel.receiveBroadcastStream().listen((event) { _eventChannel.receiveBroadcastStream().listen((event) {
final map = event as Map<dynamic, dynamic>; final map = event as Map<dynamic, dynamic>;
@ -303,9 +303,7 @@ class _CustomPlatformViewState extends State<CustomPlatformView> {
focusNode: _focusNode, focusNode: _focusNode,
canRequestFocus: true, canRequestFocus: true,
debugLabel: "flutter_inappwebview_windows_custom_platform_view", debugLabel: "flutter_inappwebview_windows_custom_platform_view",
onFocusChange: (focused) { onFocusChange: (focused) {},
},
child: SizedBox.expand(key: _key, child: _buildInner()), child: SizedBox.expand(key: _key, child: _buildInner()),
); );
} }
@ -418,7 +416,6 @@ class _CustomPlatformViewState extends State<CustomPlatformView> {
await _controller.ready; await _controller.ready;
unawaited(_controller._setSize( unawaited(_controller._setSize(
box.size, widget.scaleFactor ?? window.devicePixelRatio)); box.size, widget.scaleFactor ?? window.devicePixelRatio));
} }
} }

View File

@ -135,7 +135,8 @@ class WindowsHeadlessInAppWebViewCreationParams
PlatformHeadlessInAppWebViewCreationParams params) PlatformHeadlessInAppWebViewCreationParams params)
: this( : this(
controllerFromPlatform: params.controllerFromPlatform, controllerFromPlatform: params.controllerFromPlatform,
webViewEnvironment: params.webViewEnvironment as WindowsWebViewEnvironment?, webViewEnvironment:
params.webViewEnvironment as WindowsWebViewEnvironment?,
initialSize: params.initialSize, initialSize: params.initialSize,
windowId: params.windowId, windowId: params.windowId,
onWebViewCreated: params.onWebViewCreated, onWebViewCreated: params.onWebViewCreated,
@ -285,7 +286,8 @@ class WindowsHeadlessInAppWebView extends PlatformHeadlessInAppWebView
_init() { _init() {
_webViewController = WindowsInAppWebViewController( _webViewController = WindowsInAppWebViewController(
WindowsInAppWebViewControllerCreationParams(id: id, webviewParams: params), WindowsInAppWebViewControllerCreationParams(
id: id, webviewParams: params),
); );
_controllerFromPlatform = _controllerFromPlatform =
params.controllerFromPlatform?.call(_webViewController!) ?? params.controllerFromPlatform?.call(_webViewController!) ??

View File

@ -147,7 +147,8 @@ class WindowsInAppWebViewWidgetCreationParams
keepAlive: params.keepAlive, keepAlive: params.keepAlive,
preventGestureDelay: params.preventGestureDelay, preventGestureDelay: params.preventGestureDelay,
windowId: params.windowId, windowId: params.windowId,
webViewEnvironment: params.webViewEnvironment as WindowsWebViewEnvironment?, webViewEnvironment:
params.webViewEnvironment as WindowsWebViewEnvironment?,
onWebViewCreated: params.onWebViewCreated, onWebViewCreated: params.onWebViewCreated,
onLoadStart: params.onLoadStart, onLoadStart: params.onLoadStart,
onLoadStop: params.onLoadStop, onLoadStop: params.onLoadStop,

View File

@ -76,7 +76,8 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
Map<String, ScriptHtmlTagAttributes> _injectedScriptsFromURL = {}; Map<String, ScriptHtmlTagAttributes> _injectedScriptsFromURL = {};
Set<WindowsWebMessageChannel> _webMessageChannels = Set(); Set<WindowsWebMessageChannel> _webMessageChannels = Set();
Set<WindowsWebMessageListener> _webMessageListeners = Set(); Set<WindowsWebMessageListener> _webMessageListeners = Set();
Map<String, Function(dynamic data)> _devToolsProtocolEventListenerMap = HashMap(); Map<String, Function(dynamic data)> _devToolsProtocolEventListenerMap =
HashMap();
// static map that contains the properties to be saved and restored for keep alive feature // static map that contains the properties to be saved and restored for keep alive feature
static final Map<InAppWebViewKeepAlive, InAppWebViewControllerKeepAliveProps?> static final Map<InAppWebViewKeepAlive, InAppWebViewControllerKeepAliveProps?>
@ -94,7 +95,8 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
WindowsInAppWebViewController( WindowsInAppWebViewController(
PlatformInAppWebViewControllerCreationParams params) PlatformInAppWebViewControllerCreationParams params)
: super.implementation(params is WindowsInAppWebViewControllerCreationParams : super.implementation(params
is WindowsInAppWebViewControllerCreationParams
? params ? params
: WindowsInAppWebViewControllerCreationParams : WindowsInAppWebViewControllerCreationParams
.fromPlatformInAppWebViewControllerCreationParams(params)) { .fromPlatformInAppWebViewControllerCreationParams(params)) {
@ -134,7 +136,8 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
MethodChannel channel, MethodChannel channel,
WindowsInAppBrowser inAppBrowser, WindowsInAppBrowser inAppBrowser,
UnmodifiableListView<UserScript>? initialUserScripts) UnmodifiableListView<UserScript>? initialUserScripts)
: super.implementation(params is WindowsInAppWebViewControllerCreationParams : super.implementation(
params is WindowsInAppWebViewControllerCreationParams
? params ? params
: WindowsInAppWebViewControllerCreationParams : WindowsInAppWebViewControllerCreationParams
.fromPlatformInAppWebViewControllerCreationParams(params)) { .fromPlatformInAppWebViewControllerCreationParams(params)) {
@ -164,7 +167,8 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
webStorage = WindowsWebStorage(WindowsWebStorageCreationParams( webStorage = WindowsWebStorage(WindowsWebStorageCreationParams(
localStorage: WindowsLocalStorage.defaultStorage(controller: this), localStorage: WindowsLocalStorage.defaultStorage(controller: this),
sessionStorage: WindowsSessionStorage.defaultStorage(controller: this))); sessionStorage:
WindowsSessionStorage.defaultStorage(controller: this)));
if (params.webviewParams is PlatformInAppWebViewWidgetCreationParams) { if (params.webviewParams is PlatformInAppWebViewWidgetCreationParams) {
final keepAlive = final keepAlive =
@ -181,8 +185,8 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
webMessageListenerObjNames: _webMessageListenerObjNames, webMessageListenerObjNames: _webMessageListenerObjNames,
webMessageChannels: _webMessageChannels, webMessageChannels: _webMessageChannels,
webMessageListeners: _webMessageListeners, webMessageListeners: _webMessageListeners,
devToolsProtocolEventListenerMap: _devToolsProtocolEventListenerMap devToolsProtocolEventListenerMap:
); _devToolsProtocolEventListenerMap);
} else { } else {
// restore controller properties // restore controller properties
_injectedScriptsFromURL = props.injectedScriptsFromURL; _injectedScriptsFromURL = props.injectedScriptsFromURL;
@ -193,7 +197,8 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
props.webMessageChannels as Set<WindowsWebMessageChannel>; props.webMessageChannels as Set<WindowsWebMessageChannel>;
_webMessageListeners = _webMessageListeners =
props.webMessageListeners as Set<WindowsWebMessageListener>; props.webMessageListeners as Set<WindowsWebMessageListener>;
_devToolsProtocolEventListenerMap = props.devToolsProtocolEventListenerMap; _devToolsProtocolEventListenerMap =
props.devToolsProtocolEventListenerMap;
} }
} }
} }
@ -1409,7 +1414,9 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
break; break;
case "onDevToolsProtocolEventReceived": case "onDevToolsProtocolEventReceived":
String eventName = call.arguments["eventName"]; String eventName = call.arguments["eventName"];
dynamic data = call.arguments["data"] != null ? jsonDecode(call.arguments["data"]) : null; dynamic data = call.arguments["data"] != null
? jsonDecode(call.arguments["data"])
: null;
if (this._devToolsProtocolEventListenerMap.containsKey(eventName)) { if (this._devToolsProtocolEventListenerMap.containsKey(eventName)) {
this._devToolsProtocolEventListenerMap[eventName]!.call(data); this._devToolsProtocolEventListenerMap[eventName]!.call(data);
@ -2646,11 +2653,14 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
} }
@override @override
Future<dynamic> callDevToolsProtocolMethod({required String methodName, Map<String, dynamic>? parameters}) async { Future<dynamic> callDevToolsProtocolMethod(
{required String methodName, Map<String, dynamic>? parameters}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('methodName', () => methodName); args.putIfAbsent('methodName', () => methodName);
args.putIfAbsent('parametersAsJson', () => parameters != null ? jsonEncode(parameters) : null); args.putIfAbsent('parametersAsJson',
final result = await channel?.invokeMethod<String>('callDevToolsProtocolMethod', args); () => parameters != null ? jsonEncode(parameters) : null);
final result =
await channel?.invokeMethod<String>('callDevToolsProtocolMethod', args);
if (result != null) { if (result != null) {
return jsonDecode(result); return jsonDecode(result);
} }
@ -2658,7 +2668,9 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
} }
@override @override
Future<void> addDevToolsProtocolEventListener({required String eventName, required Function(dynamic data) callback}) async { Future<void> addDevToolsProtocolEventListener(
{required String eventName,
required Function(dynamic data) callback}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('eventName', () => eventName); args.putIfAbsent('eventName', () => eventName);
await channel?.invokeMethod('addDevToolsProtocolEventListener', args); await channel?.invokeMethod('addDevToolsProtocolEventListener', args);
@ -2666,7 +2678,8 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
} }
@override @override
Future<void> removeDevToolsProtocolEventListener({required String eventName}) async { Future<void> removeDevToolsProtocolEventListener(
{required String eventName}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('eventName', () => eventName); args.putIfAbsent('eventName', () => eventName);
await channel?.invokeMethod('removeDevToolsProtocolEventListener', args); await channel?.invokeMethod('removeDevToolsProtocolEventListener', args);

View File

@ -26,7 +26,6 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform {
return WindowsCookieManager(params); return WindowsCookieManager(params);
} }
/// Creates a new [WindowsInAppWebViewController]. /// Creates a new [WindowsInAppWebViewController].
/// ///
/// This function should only be called by the app-facing package. /// This function should only be called by the app-facing package.

View File

@ -50,8 +50,8 @@ class WindowsWebMessageChannel extends PlatformWebMessageChannel
static final WindowsWebMessageChannel _staticValue = WindowsWebMessageChannel( static final WindowsWebMessageChannel _staticValue = WindowsWebMessageChannel(
WindowsWebMessageChannelCreationParams( WindowsWebMessageChannelCreationParams(
id: '', id: '',
port1: port1: WindowsWebMessagePort(
WindowsWebMessagePort(WindowsWebMessagePortCreationParams(index: 0)), WindowsWebMessagePortCreationParams(index: 0)),
port2: WindowsWebMessagePort( port2: WindowsWebMessagePort(
WindowsWebMessagePortCreationParams(index: 1)))); WindowsWebMessagePortCreationParams(index: 1))));

View File

@ -7,7 +7,8 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla
/// Platform specific implementations can add additional fields by extending /// Platform specific implementations can add additional fields by extending
/// this class. /// this class.
@immutable @immutable
class WindowsWebViewEnvironmentCreationParams extends PlatformWebViewEnvironmentCreationParams { class WindowsWebViewEnvironmentCreationParams
extends PlatformWebViewEnvironmentCreationParams {
/// Creates a new [WindowsInAppWebViewControllerCreationParams] instance. /// Creates a new [WindowsInAppWebViewControllerCreationParams] instance.
const WindowsWebViewEnvironmentCreationParams({super.settings}); const WindowsWebViewEnvironmentCreationParams({super.settings});
@ -16,9 +17,7 @@ class WindowsWebViewEnvironmentCreationParams extends PlatformWebViewEnvironment
// Recommended placeholder to prevent being broken by platform interface. // Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters // ignore: avoid_unused_constructor_parameters
PlatformWebViewEnvironmentCreationParams params) { PlatformWebViewEnvironmentCreationParams params) {
return WindowsWebViewEnvironmentCreationParams( return WindowsWebViewEnvironmentCreationParams(settings: params.settings);
settings: params.settings
);
} }
} }
@ -28,21 +27,20 @@ class WindowsWebViewEnvironmentCreationParams extends PlatformWebViewEnvironment
///- Windows ///- Windows
class WindowsWebViewEnvironment extends PlatformWebViewEnvironment class WindowsWebViewEnvironment extends PlatformWebViewEnvironment
with ChannelController { with ChannelController {
static final MethodChannel _staticChannel = MethodChannel('com.pichillilorenzo/flutter_webview_environment'); static final MethodChannel _staticChannel =
MethodChannel('com.pichillilorenzo/flutter_webview_environment');
@override @override
final String id = IdGenerator.generate(); final String id = IdGenerator.generate();
WindowsWebViewEnvironment( WindowsWebViewEnvironment(PlatformWebViewEnvironmentCreationParams params)
PlatformWebViewEnvironmentCreationParams params)
: super.implementation(params is WindowsWebViewEnvironmentCreationParams : super.implementation(params is WindowsWebViewEnvironmentCreationParams
? params ? params
: WindowsWebViewEnvironmentCreationParams : WindowsWebViewEnvironmentCreationParams
.fromPlatformWebViewEnvironmentCreationParams(params)); .fromPlatformWebViewEnvironmentCreationParams(params));
static final WindowsWebViewEnvironment _staticValue = static final WindowsWebViewEnvironment _staticValue =
WindowsWebViewEnvironment( WindowsWebViewEnvironment(WindowsWebViewEnvironmentCreationParams());
WindowsWebViewEnvironmentCreationParams());
factory WindowsWebViewEnvironment.static() { factory WindowsWebViewEnvironment.static() {
return _staticValue; return _staticValue;
@ -52,8 +50,7 @@ class WindowsWebViewEnvironment extends PlatformWebViewEnvironment
debugLog( debugLog(
className: this.runtimeType.toString(), className: this.runtimeType.toString(),
id: id, id: id,
debugLoggingSettings: debugLoggingSettings: PlatformWebViewEnvironment.debugLoggingSettings,
PlatformWebViewEnvironment.debugLoggingSettings,
method: method, method: method,
args: args); args: args);
} }
@ -74,24 +71,22 @@ class WindowsWebViewEnvironment extends PlatformWebViewEnvironment
Future<WindowsWebViewEnvironment> create( Future<WindowsWebViewEnvironment> create(
{WebViewEnvironmentSettings? settings}) async { {WebViewEnvironmentSettings? settings}) async {
final env = WindowsWebViewEnvironment( final env = WindowsWebViewEnvironment(
WindowsWebViewEnvironmentCreationParams(settings: settings) WindowsWebViewEnvironmentCreationParams(settings: settings));
);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => env.id); args.putIfAbsent('id', () => env.id);
args.putIfAbsent('settings', () => env.settings?.toMap()); args.putIfAbsent('settings', () => env.settings?.toMap());
await _staticChannel.invokeMethod( await _staticChannel.invokeMethod('create', args);
'create', args);
env.channel = MethodChannel('com.pichillilorenzo/flutter_webview_environment_$id'); env.channel =
MethodChannel('com.pichillilorenzo/flutter_webview_environment_$id');
env.handler = env.handleMethod; env.handler = env.handleMethod;
env.initMethodCallHandler(); env.initMethodCallHandler();
return env; return env;
} }
@override @override
Future<String?> getAvailableVersion( Future<String?> getAvailableVersion({String? browserExecutableFolder}) async {
{String? browserExecutableFolder}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('browserExecutableFolder', () => browserExecutableFolder); args.putIfAbsent('browserExecutableFolder', () => browserExecutableFolder);
return await _staticChannel.invokeMethod<String>( return await _staticChannel.invokeMethod<String>(

View File

@ -11,7 +11,7 @@
"watch": "flutter pub run build_runner watch --delete-conflicting-outputs", "watch": "flutter pub run build_runner watch --delete-conflicting-outputs",
"publish:dry": "flutter pub publish --dry-run", "publish:dry": "flutter pub publish --dry-run",
"publish": "flutter pub publish", "publish": "flutter pub publish",
"format": "dart format flutter_inappwebview/lib flutter_inappwebview/example/integration_test flutter_inappwebview_platform_interface/lib flutter_inappwebview_android/lib flutter_inappwebview_ios/lib flutter_inappwebview_macos/lib flutter_inappwebview_web/lib", "format": "dart format flutter_inappwebview/lib flutter_inappwebview/example/integration_test flutter_inappwebview_platform_interface/lib flutter_inappwebview_android/lib flutter_inappwebview_ios/lib flutter_inappwebview_macos/lib flutter_inappwebview_web/lib flutter_inappwebview_windows/lib",
"build:publish": "npm run format && npm run build && flutter pub publish", "build:publish": "npm run format && npm run build && flutter pub publish",
"docs:gen": "flutter pub global activate dartdoc && flutter pub global run dartdoc:dartdoc", "docs:gen": "flutter pub global activate dartdoc && flutter pub global run dartdoc:dartdoc",
"docs:serve": "flutter pub global activate dhttpd && flutter pub global run dhttpd:dhttpd --path doc/api" "docs:serve": "flutter pub global activate dhttpd && flutter pub global run dhttpd:dhttpd --path doc/api"