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!;
} else {
return CookieManager.fromPlatformCreationParams(
PlatformCookieManagerCreationParams(webViewEnvironment: webViewEnvironment.platform)
);
PlatformCookieManagerCreationParams(
webViewEnvironment: webViewEnvironment.platform));
}
}

View File

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

View File

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

View File

@ -27,16 +27,22 @@ class WebViewEnvironment {
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.create}
static Future<WebViewEnvironment> create(
{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}
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}
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}
Future<void> dispose() => platform.dispose();

View File

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

View File

@ -40,6 +40,7 @@ class InAppBrowserSettings
///- Android native WebView
///- iOS
///- MacOS
///- Windows
bool? hidden;
///Set to `true` to hide the close button. The default value is `false`.
@ -53,6 +54,7 @@ class InAppBrowserSettings
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
bool? hideDefaultMenuItems;
///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**:
///- Android native WebView
///- MacOS
///- Windows
String? toolbarTopFixedTitle;
///Set the tint color to apply to the navigation items and bar button items.
@ -171,6 +174,7 @@ class InAppBrowserSettings
///
///**Officially Supported Platforms/Implementations**:
///- MacOS
///- Windows
double? windowAlphaValue;
///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**:
///- MacOS
///- Windows
InAppWebViewRect? windowFrame;
///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.
///
///**NOTE for MacOS**: available on MacOS 11.0+.
///
///**Officially Supported Platforms/Implementations**:
///- MacOS
///- MacOS 11.0+
WindowTitlebarSeparatorStyle? windowTitlebarSeparatorStyle;
///How the browser window should be added to the main window.
@ -199,6 +202,7 @@ class InAppBrowserSettings
///
///**Officially Supported Platforms/Implementations**:
///- MacOS
///- Windows
WindowType? windowType;
InAppBrowserSettings(
{this.allowGoBackWithBackButton = true,

View File

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

View File

@ -37,6 +37,5 @@ class InAppWebViewControllerKeepAliveProps {
this.injectedScriptsFromURL = const {},
this.webMessageChannels = 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`,
///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.
@SupportedPlatforms(
platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform(), WindowsPlatform()])
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
MacOSPlatform(),
WindowsPlatform()
])
bool? useShouldOverrideUrlLoading;
///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"),
WindowsPlatform(
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;
@ -138,8 +142,7 @@ class InAppWebViewSettings_ {
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_IsScriptEnabled",
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;
@ -320,8 +323,8 @@ because there isn't any way to make the website data store non-persistent for th
WindowsPlatform(
available: '1.0.774.44',
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;
@ -336,13 +339,14 @@ because there isn't any way to make the website data store non-persistent for th
bool? disableHorizontalScroll;
///Set to `true` to disable context menu. The default value is `false`.
@SupportedPlatforms(
platforms: [AndroidPlatform(), IOSPlatform(), WebPlatform(),
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
WebPlatform(),
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_AreDefaultContextMenusEnabled",
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;
@ -357,8 +361,7 @@ because there isn't any way to make the website data store non-persistent for th
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_IsZoomControlEnabled",
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;
@ -1566,8 +1569,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_AreDevToolsEnabled",
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;

View File

@ -2069,7 +2069,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///**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))
///{@endtemplate}
Future<dynamic> callDevToolsProtocolMethod({required String methodName, Map<String, dynamic>? parameters}) {
Future<dynamic> callDevToolsProtocolMethod(
{required String methodName, Map<String, dynamic>? parameters}) {
throw UnimplementedError(
'callDevToolsProtocolMethod is not implemented on the current platform');
}
@ -2080,7 +2081,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///**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))
///{@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(
'addDevToolsProtocolEventListener is not implemented on the current platform');
}
@ -2091,7 +2093,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///**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))
///{@endtemplate}
Future<void> removeDevToolsProtocolEventListener({required String eventName}) {
Future<void> removeDevToolsProtocolEventListener(
{required String eventName}) {
throw UnimplementedError(
'removeDevToolsProtocolEventListener is not implemented on the current platform');
}

View File

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

View File

@ -25,11 +25,10 @@ class NavigationType_ {
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated',
value: 0),
EnumWindowsPlatform(
value: 0
),
EnumWindowsPlatform(value: 0),
])
static const LINK_ACTIVATED = const NavigationType_._internal('LINK_ACTIVATED');
static const LINK_ACTIVATED =
const NavigationType_._internal('LINK_ACTIVATED');
///A form was submitted.
@EnumSupportedPlatforms(platforms: [
@ -44,7 +43,8 @@ class NavigationType_ {
'https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted',
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.
@EnumSupportedPlatforms(platforms: [
@ -62,8 +62,7 @@ class NavigationType_ {
apiName: 'COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD',
apiUrl:
'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');
@ -83,8 +82,7 @@ class NavigationType_ {
apiName: 'COREWEBVIEW2_NAVIGATION_KIND_RELOAD',
apiUrl:
'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');
@ -101,7 +99,8 @@ class NavigationType_ {
'https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted',
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.
@EnumSupportedPlatforms(platforms: [
@ -115,9 +114,7 @@ class NavigationType_ {
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/other',
value: -1),
EnumWindowsPlatform(
value: 3
),
EnumWindowsPlatform(value: 3),
])
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 default value of this property is `null`, which returns an image whose size matches the original size of the captured rectangle.
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
MacOSPlatform()
])
@SupportedPlatforms(
platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
double? snapshotWidth;
///The compression format of the captured image.

View File

@ -25,11 +25,14 @@ class WebHistoryItem_ {
int? offset;
///Unique id of the navigation history entry.
@SupportedPlatforms(platforms: [
WindowsPlatform()
])
@SupportedPlatforms(platforms: [WindowsPlatform()])
int? entryId;
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',
value: -1011),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE',
apiName:
'COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE',
apiUrl:
'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)
@ -426,7 +427,8 @@ class WebResourceErrorType_ {
'https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired',
value: -1013),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED',
apiName:
'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED',
apiUrl:
'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),
@ -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',
value: 6),
])
static const SERVER_UNREACHABLE = WebResourceErrorType_._internal("SERVER_UNREACHABLE");
static const SERVER_UNREACHABLE =
WebResourceErrorType_._internal("SERVER_UNREACHABLE");
///Indicates that the connection was stopped.
@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',
value: 9)
])
static const CONNECTION_ABORTED = WebResourceErrorType_._internal("CONNECTION_ABORTED");
static const CONNECTION_ABORTED =
WebResourceErrorType_._internal("CONNECTION_ABORTED");
///Indicates that the connection was reset.
@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',
value: 15),
])
static const REDIRECT_FAILED = WebResourceErrorType_._internal("REDIRECT_FAILED");
static const REDIRECT_FAILED =
WebResourceErrorType_._internal("REDIRECT_FAILED");
///Indicates that an unexpected error occurred.
@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',
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.
@EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED',
apiName:
'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED',
apiUrl:
'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),
])
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);
///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');
///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');
///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
implements Disposable {
///Debug settings used by [PlatformWebViewEnvironment].
static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(
maxLogMessageLength: 1000
);
static DebugLoggingSettings debugLoggingSettings =
DebugLoggingSettings(maxLogMessageLength: 1000);
/// Creates a new [PlatformInAppWebViewController]
factory PlatformWebViewEnvironment(
@ -42,8 +41,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
'`InAppWebViewPlatform.instance` can be set with your own test implementation.',
);
final PlatformWebViewEnvironment webViewEnvironment =
InAppWebViewPlatform.instance!
.createPlatformWebViewEnvironment(params);
InAppWebViewPlatform.instance!.createPlatformWebViewEnvironment(params);
PlatformInterface.verify(webViewEnvironment, _token);
return webViewEnvironment;
}
@ -58,8 +56,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
'`InAppWebViewPlatform.instance` can be set with your own test implementation.',
);
final PlatformWebViewEnvironment webViewEnvironment =
InAppWebViewPlatform.instance!
.createPlatformWebViewEnvironmentStatic();
InAppWebViewPlatform.instance!.createPlatformWebViewEnvironmentStatic();
PlatformInterface.verify(webViewEnvironment, _token);
return webViewEnvironment;
}
@ -69,8 +66,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
/// Should only be used by platform implementations because they can't extend
/// a class that only contains a factory constructor.
@protected
PlatformWebViewEnvironment.implementation(this.params)
: super(token: _token);
PlatformWebViewEnvironment.implementation(this.params) : super(token: _token);
static final Object _token = Object();
@ -114,8 +110,7 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
///**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))
///{@endtemplate}
Future<String?> getAvailableVersion(
{String? browserExecutableFolder}) {
Future<String?> getAvailableVersion({String? browserExecutableFolder}) {
throw UnimplementedError(
'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]
///may be overridden by values either specified in environment variables or in the registry.
@SupportedPlatforms(platforms: [
WindowsPlatform()
])
@SupportedPlatforms(platforms: [WindowsPlatform()])
@ExchangeableObject(copyMethod: true)
class WebViewEnvironmentSettings_ {
///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
///applicable `releaseChannelPreference` registry value is set to `1`, the channel search order is reversed.
@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;
@ -48,7 +50,10 @@ class WebViewEnvironmentSettings_ {
///options does not match the options of the WebViews that are currently
///running in the shared browser process.
@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;
@ -57,35 +62,49 @@ class WebViewEnvironmentSettings_ {
///in which case the features should be comma-seperated.
///Example: `"--disable-features=feature1,feature2 --some-other-switch --do-something"`
@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;
///This property is used to enable single sign on with Azure Active Directory (AAD)
///and personal Microsoft Account (MSA) resources inside WebView.
@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;
///The default display language for WebView.
@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;
///Specifies the version of the WebView2 Runtime binaries required to be compatible with your app.
@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;
WebViewEnvironmentSettings_({
this.browserExecutableFolder,
WebViewEnvironmentSettings_(
{this.browserExecutableFolder,
this.userDataFolder,
this.additionalBrowserArguments,
this.allowSingleSignOnUsingOSPrimaryAccount,
this.language,
this.targetCompatibleBrowserVersion
});
this.targetCompatibleBrowserVersion});
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,6 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform {
return WindowsCookieManager(params);
}
/// Creates a new [WindowsInAppWebViewController].
///
/// 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(
WindowsWebMessageChannelCreationParams(
id: '',
port1:
WindowsWebMessagePort(WindowsWebMessagePortCreationParams(index: 0)),
port1: WindowsWebMessagePort(
WindowsWebMessagePortCreationParams(index: 0)),
port2: WindowsWebMessagePort(
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
/// this class.
@immutable
class WindowsWebViewEnvironmentCreationParams extends PlatformWebViewEnvironmentCreationParams {
class WindowsWebViewEnvironmentCreationParams
extends PlatformWebViewEnvironmentCreationParams {
/// Creates a new [WindowsInAppWebViewControllerCreationParams] instance.
const WindowsWebViewEnvironmentCreationParams({super.settings});
@ -16,9 +17,7 @@ class WindowsWebViewEnvironmentCreationParams extends PlatformWebViewEnvironment
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformWebViewEnvironmentCreationParams params) {
return WindowsWebViewEnvironmentCreationParams(
settings: params.settings
);
return WindowsWebViewEnvironmentCreationParams(settings: params.settings);
}
}
@ -28,21 +27,20 @@ class WindowsWebViewEnvironmentCreationParams extends PlatformWebViewEnvironment
///- Windows
class WindowsWebViewEnvironment extends PlatformWebViewEnvironment
with ChannelController {
static final MethodChannel _staticChannel = MethodChannel('com.pichillilorenzo/flutter_webview_environment');
static final MethodChannel _staticChannel =
MethodChannel('com.pichillilorenzo/flutter_webview_environment');
@override
final String id = IdGenerator.generate();
WindowsWebViewEnvironment(
PlatformWebViewEnvironmentCreationParams params)
WindowsWebViewEnvironment(PlatformWebViewEnvironmentCreationParams params)
: super.implementation(params is WindowsWebViewEnvironmentCreationParams
? params
: WindowsWebViewEnvironmentCreationParams
.fromPlatformWebViewEnvironmentCreationParams(params));
static final WindowsWebViewEnvironment _staticValue =
WindowsWebViewEnvironment(
WindowsWebViewEnvironmentCreationParams());
WindowsWebViewEnvironment(WindowsWebViewEnvironmentCreationParams());
factory WindowsWebViewEnvironment.static() {
return _staticValue;
@ -52,8 +50,7 @@ class WindowsWebViewEnvironment extends PlatformWebViewEnvironment
debugLog(
className: this.runtimeType.toString(),
id: id,
debugLoggingSettings:
PlatformWebViewEnvironment.debugLoggingSettings,
debugLoggingSettings: PlatformWebViewEnvironment.debugLoggingSettings,
method: method,
args: args);
}
@ -74,24 +71,22 @@ class WindowsWebViewEnvironment extends PlatformWebViewEnvironment
Future<WindowsWebViewEnvironment> create(
{WebViewEnvironmentSettings? settings}) async {
final env = WindowsWebViewEnvironment(
WindowsWebViewEnvironmentCreationParams(settings: settings)
);
WindowsWebViewEnvironmentCreationParams(settings: settings));
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => env.id);
args.putIfAbsent('settings', () => env.settings?.toMap());
await _staticChannel.invokeMethod(
'create', args);
await _staticChannel.invokeMethod('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.initMethodCallHandler();
return env;
}
@override
Future<String?> getAvailableVersion(
{String? browserExecutableFolder}) async {
Future<String?> getAvailableVersion({String? browserExecutableFolder}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('browserExecutableFolder', () => browserExecutableFolder);
return await _staticChannel.invokeMethod<String>(

View File

@ -11,7 +11,7 @@
"watch": "flutter pub run build_runner watch --delete-conflicting-outputs",
"publish:dry": "flutter pub publish --dry-run",
"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",
"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"