removed util platform check
This commit is contained in:
parent
e0c03b0891
commit
b66eeae75a
@ -262,16 +262,11 @@ class AndroidInAppWebViewWidgetCreationParams
|
|||||||
final AndroidPullToRefreshController? pullToRefreshController;
|
final AndroidPullToRefreshController? pullToRefreshController;
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@template flutter_inappwebview.InAppWebView}
|
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
|
||||||
///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree.
|
|
||||||
///
|
|
||||||
///**Supported Platforms/Implementations**:
|
|
||||||
///- Android native WebView
|
|
||||||
///- iOS
|
|
||||||
///- Web
|
|
||||||
///{@endtemplate}
|
|
||||||
class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
||||||
/// Constructs a [AndroidInAppWebViewWidget].
|
/// Constructs a [AndroidInAppWebViewWidget].
|
||||||
|
///
|
||||||
|
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
|
||||||
AndroidInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params)
|
AndroidInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is AndroidInAppWebViewWidgetCreationParams
|
params is AndroidInAppWebViewWidgetCreationParams
|
||||||
|
@ -2455,7 +2455,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController
|
|||||||
@override
|
@override
|
||||||
Future<void> removeUserScripts(
|
Future<void> removeUserScripts(
|
||||||
{required List<UserScript> userScripts}) async {
|
{required List<UserScript> userScripts}) async {
|
||||||
for (final userScript in userScripts) {
|
for (final userScript in userScripts) {
|
||||||
await removeUserScript(userScript: userScript);
|
await removeUserScript(userScript: userScript);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,9 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser
|
|||||||
assert(!_isOpened, 'The browser is already opened.');
|
assert(!_isOpened, 'The browser is already opened.');
|
||||||
_isOpened = true;
|
_isOpened = true;
|
||||||
|
|
||||||
if (Util.isIOS) {
|
assert(url != null, 'The specified URL must not be null on iOS.');
|
||||||
assert(url != null, 'The specified URL must not be null on iOS.');
|
assert(['http', 'https'].contains(url!.scheme),
|
||||||
assert(['http', 'https'].contains(url!.scheme),
|
'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
|
||||||
'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
|
|
||||||
}
|
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
assert(url.toString().isNotEmpty, 'The specified URL must not be empty.');
|
assert(url.toString().isNotEmpty, 'The specified URL must not be empty.');
|
||||||
}
|
}
|
||||||
|
@ -418,14 +418,9 @@ class IOSCookieManager extends PlatformCookieManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _shouldUseJavascript() async {
|
Future<bool> _shouldUseJavascript() async {
|
||||||
if (Util.isIOS || Util.isMacOS) {
|
final platformUtil = PlatformUtil.instance();
|
||||||
final platformUtil = PlatformUtil.instance();
|
final systemVersion = await platformUtil.getSystemVersion();
|
||||||
final systemVersion = await platformUtil.getSystemVersion();
|
return systemVersion.compareTo("10.13") == -1;
|
||||||
return Util.isIOS
|
|
||||||
? systemVersion.compareTo("11") == -1
|
|
||||||
: systemVersion.compareTo("10.13") == -1;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -260,16 +260,11 @@ class IOSInAppWebViewWidgetCreationParams
|
|||||||
final IOSPullToRefreshController? pullToRefreshController;
|
final IOSPullToRefreshController? pullToRefreshController;
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@template flutter_inappwebview.InAppWebView}
|
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
|
||||||
///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree.
|
|
||||||
///
|
|
||||||
///**Supported Platforms/Implementations**:
|
|
||||||
///- IOS native WebView
|
|
||||||
///- iOS
|
|
||||||
///- Web
|
|
||||||
///{@endtemplate}
|
|
||||||
class IOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
class IOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
||||||
/// Constructs a [IOSInAppWebViewWidget].
|
/// Constructs a [IOSInAppWebViewWidget].
|
||||||
|
///
|
||||||
|
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
|
||||||
IOSInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params)
|
IOSInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is IOSInAppWebViewWidgetCreationParams
|
params is IOSInAppWebViewWidgetCreationParams
|
||||||
|
@ -90,10 +90,8 @@ class IOSWebAuthenticationSession extends PlatformWebAuthenticationSession
|
|||||||
WebAuthenticationSessionSettings? initialSettings})
|
WebAuthenticationSessionSettings? initialSettings})
|
||||||
: super.implementation(IOSWebAuthenticationSessionCreationParams()) {
|
: super.implementation(IOSWebAuthenticationSessionCreationParams()) {
|
||||||
assert(url.toString().isNotEmpty);
|
assert(url.toString().isNotEmpty);
|
||||||
if (Util.isIOS || Util.isMacOS) {
|
assert(['http', 'https'].contains(url.scheme),
|
||||||
assert(['http', 'https'].contains(url.scheme),
|
'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
|
||||||
'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.initialSettings =
|
this.initialSettings =
|
||||||
initialSettings ?? WebAuthenticationSessionSettings();
|
initialSettings ?? WebAuthenticationSessionSettings();
|
||||||
|
@ -418,14 +418,9 @@ class MacOSCookieManager extends PlatformCookieManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _shouldUseJavascript() async {
|
Future<bool> _shouldUseJavascript() async {
|
||||||
if (Util.isMacOS || Util.isMacOS) {
|
final platformUtil = PlatformUtil.instance();
|
||||||
final platformUtil = PlatformUtil.instance();
|
final systemVersion = await platformUtil.getSystemVersion();
|
||||||
final systemVersion = await platformUtil.getSystemVersion();
|
return systemVersion.compareTo("11") == -1;
|
||||||
return Util.isMacOS
|
|
||||||
? systemVersion.compareTo("11") == -1
|
|
||||||
: systemVersion.compareTo("10.13") == -1;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -65,7 +65,7 @@ class MacOSInAppBrowser extends PlatformInAppBrowser with ChannelController {
|
|||||||
return _staticValue;
|
return _staticValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacOSInAppBrowserCreationParams get _iosParams =>
|
MacOSInAppBrowserCreationParams get _macosParams =>
|
||||||
params as MacOSInAppBrowserCreationParams;
|
params as MacOSInAppBrowserCreationParams;
|
||||||
|
|
||||||
static const MethodChannel _staticChannel =
|
static const MethodChannel _staticChannel =
|
||||||
@ -95,7 +95,7 @@ class MacOSInAppBrowser extends PlatformInAppBrowser with ChannelController {
|
|||||||
channel!,
|
channel!,
|
||||||
this,
|
this,
|
||||||
this.initialUserScripts);
|
this.initialUserScripts);
|
||||||
_iosParams.findInteractionController?.init(id);
|
_macosParams.findInteractionController?.init(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
_debugLog(String method, dynamic args) {
|
_debugLog(String method, dynamic args) {
|
||||||
|
@ -274,7 +274,7 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView
|
|||||||
|
|
||||||
dynamic _controllerFromPlatform;
|
dynamic _controllerFromPlatform;
|
||||||
|
|
||||||
MacOSHeadlessInAppWebViewCreationParams get _iosParams =>
|
MacOSHeadlessInAppWebViewCreationParams get _macosParams =>
|
||||||
params as MacOSHeadlessInAppWebViewCreationParams;
|
params as MacOSHeadlessInAppWebViewCreationParams;
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
@ -285,7 +285,7 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView
|
|||||||
_controllerFromPlatform =
|
_controllerFromPlatform =
|
||||||
params.controllerFromPlatform?.call(_webViewController!) ??
|
params.controllerFromPlatform?.call(_webViewController!) ??
|
||||||
_webViewController!;
|
_webViewController!;
|
||||||
_iosParams.findInteractionController?.init(id);
|
_macosParams.findInteractionController?.init(id);
|
||||||
channel =
|
channel =
|
||||||
MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview_$id');
|
MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview_$id');
|
||||||
handler = _handleMethod;
|
handler = _handleMethod;
|
||||||
@ -321,8 +321,8 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView
|
|||||||
initialSettings.toMap();
|
initialSettings.toMap();
|
||||||
|
|
||||||
Map<String, dynamic> pullToRefreshSettings =
|
Map<String, dynamic> pullToRefreshSettings =
|
||||||
_iosParams.pullToRefreshController?.params.settings.toMap() ??
|
_macosParams.pullToRefreshController?.params.settings.toMap() ??
|
||||||
_iosParams.pullToRefreshController?.params.options.toMap() ??
|
_macosParams.pullToRefreshController?.params.options.toMap() ??
|
||||||
PullToRefreshSettings(enabled: false).toMap();
|
PullToRefreshSettings(enabled: false).toMap();
|
||||||
|
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
@ -421,8 +421,8 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView
|
|||||||
_webViewController?.dispose();
|
_webViewController?.dispose();
|
||||||
_webViewController = null;
|
_webViewController = null;
|
||||||
_controllerFromPlatform = null;
|
_controllerFromPlatform = null;
|
||||||
_iosParams.pullToRefreshController?.dispose();
|
_macosParams.pullToRefreshController?.dispose();
|
||||||
_iosParams.findInteractionController?.dispose();
|
_macosParams.findInteractionController?.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,16 +254,11 @@ class MacOSInAppWebViewWidgetCreationParams
|
|||||||
final MacOSFindInteractionController? findInteractionController;
|
final MacOSFindInteractionController? findInteractionController;
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@template flutter_inappwebview.InAppWebView}
|
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
|
||||||
///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree.
|
|
||||||
///
|
|
||||||
///**Supported Platforms/Implementations**:
|
|
||||||
///- MacOS native WebView
|
|
||||||
///- iOS
|
|
||||||
///- Web
|
|
||||||
///{@endtemplate}
|
|
||||||
class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
||||||
/// Constructs a [MacOSInAppWebViewWidget].
|
/// Constructs a [MacOSInAppWebViewWidget].
|
||||||
|
///
|
||||||
|
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
|
||||||
MacOSInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params)
|
MacOSInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSInAppWebViewWidgetCreationParams
|
params is MacOSInAppWebViewWidgetCreationParams
|
||||||
@ -272,61 +267,61 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
|||||||
.fromPlatformInAppWebViewWidgetCreationParams(params),
|
.fromPlatformInAppWebViewWidgetCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
MacOSInAppWebViewWidgetCreationParams get _iosParams =>
|
MacOSInAppWebViewWidgetCreationParams get _macosParams =>
|
||||||
params as MacOSInAppWebViewWidgetCreationParams;
|
params as MacOSInAppWebViewWidgetCreationParams;
|
||||||
|
|
||||||
MacOSInAppWebViewController? _controller;
|
MacOSInAppWebViewController? _controller;
|
||||||
|
|
||||||
MacOSHeadlessInAppWebView? get _iosHeadlessInAppWebView =>
|
MacOSHeadlessInAppWebView? get _macosHeadlessInAppWebView =>
|
||||||
_iosParams.headlessWebView as MacOSHeadlessInAppWebView?;
|
_macosParams.headlessWebView as MacOSHeadlessInAppWebView?;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final initialSettings =
|
final initialSettings =
|
||||||
_iosParams.initialSettings ?? InAppWebViewSettings();
|
_macosParams.initialSettings ?? InAppWebViewSettings();
|
||||||
_inferInitialSettings(initialSettings);
|
_inferInitialSettings(initialSettings);
|
||||||
|
|
||||||
Map<String, dynamic> settingsMap = (_iosParams.initialSettings != null
|
Map<String, dynamic> settingsMap = (_macosParams.initialSettings != null
|
||||||
? initialSettings.toMap()
|
? initialSettings.toMap()
|
||||||
: null) ??
|
: null) ??
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
_iosParams.initialOptions?.toMap() ??
|
_macosParams.initialOptions?.toMap() ??
|
||||||
initialSettings.toMap();
|
initialSettings.toMap();
|
||||||
|
|
||||||
Map<String, dynamic> pullToRefreshSettings =
|
Map<String, dynamic> pullToRefreshSettings =
|
||||||
_iosParams.pullToRefreshController?.params.settings.toMap() ??
|
_macosParams.pullToRefreshController?.params.settings.toMap() ??
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
_iosParams.pullToRefreshController?.params.options.toMap() ??
|
_macosParams.pullToRefreshController?.params.options.toMap() ??
|
||||||
PullToRefreshSettings(enabled: false).toMap();
|
PullToRefreshSettings(enabled: false).toMap();
|
||||||
|
|
||||||
if ((_iosParams.headlessWebView?.isRunning() ?? false) &&
|
if ((_macosParams.headlessWebView?.isRunning() ?? false) &&
|
||||||
_iosParams.keepAlive != null) {
|
_macosParams.keepAlive != null) {
|
||||||
final headlessId = _iosParams.headlessWebView?.id;
|
final headlessId = _macosParams.headlessWebView?.id;
|
||||||
if (headlessId != null) {
|
if (headlessId != null) {
|
||||||
// force keep alive id to match headless webview id
|
// force keep alive id to match headless webview id
|
||||||
_iosParams.keepAlive?.id = headlessId;
|
_macosParams.keepAlive?.id = headlessId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return UiKitView(
|
return UiKitView(
|
||||||
viewType: 'com.pichillilorenzo/flutter_inappwebview',
|
viewType: 'com.pichillilorenzo/flutter_inappwebview',
|
||||||
onPlatformViewCreated: _onPlatformViewCreated,
|
onPlatformViewCreated: _onPlatformViewCreated,
|
||||||
gestureRecognizers: _iosParams.gestureRecognizers,
|
gestureRecognizers: _macosParams.gestureRecognizers,
|
||||||
creationParams: <String, dynamic>{
|
creationParams: <String, dynamic>{
|
||||||
'initialUrlRequest': _iosParams.initialUrlRequest?.toMap(),
|
'initialUrlRequest': _macosParams.initialUrlRequest?.toMap(),
|
||||||
'initialFile': _iosParams.initialFile,
|
'initialFile': _macosParams.initialFile,
|
||||||
'initialData': _iosParams.initialData?.toMap(),
|
'initialData': _macosParams.initialData?.toMap(),
|
||||||
'initialSettings': settingsMap,
|
'initialSettings': settingsMap,
|
||||||
'contextMenu': _iosParams.contextMenu?.toMap() ?? {},
|
'contextMenu': _macosParams.contextMenu?.toMap() ?? {},
|
||||||
'windowId': _iosParams.windowId,
|
'windowId': _macosParams.windowId,
|
||||||
'headlessWebViewId': _iosParams.headlessWebView?.isRunning() ?? false
|
'headlessWebViewId': _macosParams.headlessWebView?.isRunning() ?? false
|
||||||
? _iosParams.headlessWebView?.id
|
? _macosParams.headlessWebView?.id
|
||||||
: null,
|
: null,
|
||||||
'initialUserScripts':
|
'initialUserScripts':
|
||||||
_iosParams.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
|
_macosParams.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
|
||||||
'pullToRefreshSettings': pullToRefreshSettings,
|
'pullToRefreshSettings': pullToRefreshSettings,
|
||||||
'keepAliveId': _iosParams.keepAlive?.id,
|
'keepAliveId': _macosParams.keepAlive?.id,
|
||||||
'preventGestureDelay': _iosParams.preventGestureDelay
|
'preventGestureDelay': _macosParams.preventGestureDelay
|
||||||
},
|
},
|
||||||
creationParamsCodec: const StandardMessageCodec(),
|
creationParamsCodec: const StandardMessageCodec(),
|
||||||
);
|
);
|
||||||
@ -335,16 +330,16 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
|||||||
void _onPlatformViewCreated(int id) {
|
void _onPlatformViewCreated(int id) {
|
||||||
dynamic viewId = id;
|
dynamic viewId = id;
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
if (_iosParams.headlessWebView?.isRunning() ?? false) {
|
if (_macosParams.headlessWebView?.isRunning() ?? false) {
|
||||||
viewId = _iosParams.headlessWebView?.id;
|
viewId = _macosParams.headlessWebView?.id;
|
||||||
}
|
}
|
||||||
viewId = _iosParams.keepAlive?.id ?? viewId ?? id;
|
viewId = _macosParams.keepAlive?.id ?? viewId ?? id;
|
||||||
}
|
}
|
||||||
_iosHeadlessInAppWebView?.internalDispose();
|
_macosHeadlessInAppWebView?.internalDispose();
|
||||||
_controller = MacOSInAppWebViewController(
|
_controller = MacOSInAppWebViewController(
|
||||||
PlatformInAppWebViewControllerCreationParams(
|
PlatformInAppWebViewControllerCreationParams(
|
||||||
id: viewId, webviewParams: params));
|
id: viewId, webviewParams: params));
|
||||||
_iosParams.findInteractionController?.init(viewId);
|
_macosParams.findInteractionController?.init(viewId);
|
||||||
debugLog(
|
debugLog(
|
||||||
className: runtimeType.toString(),
|
className: runtimeType.toString(),
|
||||||
id: viewId?.toString(),
|
id: viewId?.toString(),
|
||||||
@ -352,42 +347,42 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
|||||||
PlatformInAppWebViewController.debugLoggingSettings,
|
PlatformInAppWebViewController.debugLoggingSettings,
|
||||||
method: "onWebViewCreated",
|
method: "onWebViewCreated",
|
||||||
args: []);
|
args: []);
|
||||||
if (_iosParams.onWebViewCreated != null) {
|
if (_macosParams.onWebViewCreated != null) {
|
||||||
_iosParams.onWebViewCreated!(
|
_macosParams.onWebViewCreated!(
|
||||||
params.controllerFromPlatform?.call(_controller!) ?? _controller!);
|
params.controllerFromPlatform?.call(_controller!) ?? _controller!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _inferInitialSettings(InAppWebViewSettings settings) {
|
void _inferInitialSettings(InAppWebViewSettings settings) {
|
||||||
if (_iosParams.shouldOverrideUrlLoading != null &&
|
if (_macosParams.shouldOverrideUrlLoading != null &&
|
||||||
settings.useShouldOverrideUrlLoading == null) {
|
settings.useShouldOverrideUrlLoading == null) {
|
||||||
settings.useShouldOverrideUrlLoading = true;
|
settings.useShouldOverrideUrlLoading = true;
|
||||||
}
|
}
|
||||||
if (_iosParams.onLoadResource != null &&
|
if (_macosParams.onLoadResource != null &&
|
||||||
settings.useOnLoadResource == null) {
|
settings.useOnLoadResource == null) {
|
||||||
settings.useOnLoadResource = true;
|
settings.useOnLoadResource = true;
|
||||||
}
|
}
|
||||||
if (_iosParams.onDownloadStartRequest != null &&
|
if (_macosParams.onDownloadStartRequest != null &&
|
||||||
settings.useOnDownloadStart == null) {
|
settings.useOnDownloadStart == null) {
|
||||||
settings.useOnDownloadStart = true;
|
settings.useOnDownloadStart = true;
|
||||||
}
|
}
|
||||||
if (_iosParams.shouldInterceptAjaxRequest != null &&
|
if (_macosParams.shouldInterceptAjaxRequest != null &&
|
||||||
settings.useShouldInterceptAjaxRequest == null) {
|
settings.useShouldInterceptAjaxRequest == null) {
|
||||||
settings.useShouldInterceptAjaxRequest = true;
|
settings.useShouldInterceptAjaxRequest = true;
|
||||||
}
|
}
|
||||||
if (_iosParams.shouldInterceptFetchRequest != null &&
|
if (_macosParams.shouldInterceptFetchRequest != null &&
|
||||||
settings.useShouldInterceptFetchRequest == null) {
|
settings.useShouldInterceptFetchRequest == null) {
|
||||||
settings.useShouldInterceptFetchRequest = true;
|
settings.useShouldInterceptFetchRequest = true;
|
||||||
}
|
}
|
||||||
if (_iosParams.shouldInterceptRequest != null &&
|
if (_macosParams.shouldInterceptRequest != null &&
|
||||||
settings.useShouldInterceptRequest == null) {
|
settings.useShouldInterceptRequest == null) {
|
||||||
settings.useShouldInterceptRequest = true;
|
settings.useShouldInterceptRequest = true;
|
||||||
}
|
}
|
||||||
if (_iosParams.onRenderProcessGone != null &&
|
if (_macosParams.onRenderProcessGone != null &&
|
||||||
settings.useOnRenderProcessGone == null) {
|
settings.useOnRenderProcessGone == null) {
|
||||||
settings.useOnRenderProcessGone = true;
|
settings.useOnRenderProcessGone = true;
|
||||||
}
|
}
|
||||||
if (_iosParams.onNavigationResponse != null &&
|
if (_macosParams.onNavigationResponse != null &&
|
||||||
settings.useOnNavigationResponse == null) {
|
settings.useOnNavigationResponse == null) {
|
||||||
settings.useOnNavigationResponse = true;
|
settings.useOnNavigationResponse = true;
|
||||||
}
|
}
|
||||||
@ -403,11 +398,11 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget {
|
|||||||
PlatformInAppWebViewController.debugLoggingSettings,
|
PlatformInAppWebViewController.debugLoggingSettings,
|
||||||
method: "dispose",
|
method: "dispose",
|
||||||
args: []);
|
args: []);
|
||||||
final isKeepAlive = _iosParams.keepAlive != null;
|
final isKeepAlive = _macosParams.keepAlive != null;
|
||||||
_controller?.dispose(isKeepAlive: isKeepAlive);
|
_controller?.dispose(isKeepAlive: isKeepAlive);
|
||||||
_controller = null;
|
_controller = null;
|
||||||
_iosParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive);
|
_macosParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive);
|
||||||
_iosParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive);
|
_macosParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -48,16 +48,17 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
|
|||||||
return MacOSInAppWebViewController.static();
|
return MacOSInAppWebViewController.static();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [MacOSInAppWebViewWidget].
|
// TODO: unhide when Flutter official PlatformView for macOS is available
|
||||||
///
|
// /// Creates a new [MacOSInAppWebViewWidget].
|
||||||
/// This function should only be called by the app-facing package.
|
// ///
|
||||||
/// Look at using [InAppWebView] in `flutter_inappwebview` instead.
|
// /// This function should only be called by the app-facing package.
|
||||||
@override
|
// /// Look at using [InAppWebView] in `flutter_inappwebview` instead.
|
||||||
MacOSInAppWebViewWidget createPlatformInAppWebViewWidget(
|
// @override
|
||||||
PlatformInAppWebViewWidgetCreationParams params,
|
// MacOSInAppWebViewWidget createPlatformInAppWebViewWidget(
|
||||||
) {
|
// PlatformInAppWebViewWidgetCreationParams params,
|
||||||
return MacOSInAppWebViewWidget(params);
|
// ) {
|
||||||
}
|
// return MacOSInAppWebViewWidget(params);
|
||||||
|
// }
|
||||||
|
|
||||||
/// Creates a new [MacOSFindInteractionController].
|
/// Creates a new [MacOSFindInteractionController].
|
||||||
///
|
///
|
||||||
|
@ -90,10 +90,8 @@ class MacOSWebAuthenticationSession extends PlatformWebAuthenticationSession
|
|||||||
WebAuthenticationSessionSettings? initialSettings})
|
WebAuthenticationSessionSettings? initialSettings})
|
||||||
: super.implementation(MacOSWebAuthenticationSessionCreationParams()) {
|
: super.implementation(MacOSWebAuthenticationSessionCreationParams()) {
|
||||||
assert(url.toString().isNotEmpty);
|
assert(url.toString().isNotEmpty);
|
||||||
if (Util.isMacOS || Util.isMacOS) {
|
assert(['http', 'https'].contains(url.scheme),
|
||||||
assert(['http', 'https'].contains(url.scheme),
|
'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
|
||||||
'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.initialSettings =
|
this.initialSettings =
|
||||||
initialSettings ?? WebAuthenticationSessionSettings();
|
initialSettings ?? WebAuthenticationSessionSettings();
|
||||||
|
@ -60,9 +60,9 @@ class MacOSWebMessageChannel extends PlatformWebMessageChannel
|
|||||||
return _staticValue;
|
return _staticValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacOSWebMessagePort get _iosPort1 => port1 as MacOSWebMessagePort;
|
MacOSWebMessagePort get _macosPort1 => port1 as MacOSWebMessagePort;
|
||||||
|
|
||||||
MacOSWebMessagePort get _iosPort2 => port2 as MacOSWebMessagePort;
|
MacOSWebMessagePort get _macosPort2 => port2 as MacOSWebMessagePort;
|
||||||
|
|
||||||
static MacOSWebMessageChannel? _fromMap(Map<String, dynamic>? map) {
|
static MacOSWebMessageChannel? _fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
@ -75,8 +75,8 @@ class MacOSWebMessageChannel extends PlatformWebMessageChannel
|
|||||||
MacOSWebMessagePortCreationParams(index: 0)),
|
MacOSWebMessagePortCreationParams(index: 0)),
|
||||||
port2: MacOSWebMessagePort(
|
port2: MacOSWebMessagePort(
|
||||||
MacOSWebMessagePortCreationParams(index: 1))));
|
MacOSWebMessagePortCreationParams(index: 1))));
|
||||||
webMessageChannel._iosPort1.webMessageChannel = webMessageChannel;
|
webMessageChannel._macosPort1.webMessageChannel = webMessageChannel;
|
||||||
webMessageChannel._iosPort2.webMessageChannel = webMessageChannel;
|
webMessageChannel._macosPort2.webMessageChannel = webMessageChannel;
|
||||||
return webMessageChannel;
|
return webMessageChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class MacOSWebMessageChannel extends PlatformWebMessageChannel
|
|||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "onMessage":
|
case "onMessage":
|
||||||
int index = call.arguments["index"];
|
int index = call.arguments["index"];
|
||||||
var port = index == 0 ? _iosPort1 : _iosPort2;
|
var port = index == 0 ? _macosPort1 : _macosPort2;
|
||||||
if (port.onMessage != null) {
|
if (port.onMessage != null) {
|
||||||
WebMessage? message = call.arguments["message"] != null
|
WebMessage? message = call.arguments["message"] != null
|
||||||
? WebMessage.fromMap(
|
? WebMessage.fromMap(
|
||||||
|
@ -47,7 +47,7 @@ class MacOSWebMessageListener extends PlatformWebMessageListener
|
|||||||
: MacOSWebMessageListenerCreationParams
|
: MacOSWebMessageListenerCreationParams
|
||||||
.fromPlatformWebMessageListenerCreationParams(params),
|
.fromPlatformWebMessageListenerCreationParams(params),
|
||||||
) {
|
) {
|
||||||
assert(!this._iosParams.allowedOriginRules.contains(""),
|
assert(!this._macosParams.allowedOriginRules.contains(""),
|
||||||
"allowedOriginRules cannot contain empty strings");
|
"allowedOriginRules cannot contain empty strings");
|
||||||
channel = MethodChannel(
|
channel = MethodChannel(
|
||||||
'com.pichillilorenzo/flutter_inappwebview_web_message_listener_${_id}_${params.jsObjectName}');
|
'com.pichillilorenzo/flutter_inappwebview_web_message_listener_${_id}_${params.jsObjectName}');
|
||||||
@ -60,7 +60,7 @@ class MacOSWebMessageListener extends PlatformWebMessageListener
|
|||||||
|
|
||||||
MacOSJavaScriptReplyProxy? _replyProxy;
|
MacOSJavaScriptReplyProxy? _replyProxy;
|
||||||
|
|
||||||
MacOSWebMessageListenerCreationParams get _iosParams =>
|
MacOSWebMessageListenerCreationParams get _macosParams =>
|
||||||
params as MacOSWebMessageListenerCreationParams;
|
params as MacOSWebMessageListenerCreationParams;
|
||||||
|
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
@ -99,7 +99,7 @@ class MacOSWebMessageListener extends PlatformWebMessageListener
|
|||||||
return {
|
return {
|
||||||
"id": _id,
|
"id": _id,
|
||||||
"jsObjectName": params.jsObjectName,
|
"jsObjectName": params.jsObjectName,
|
||||||
"allowedOriginRules": _iosParams.allowedOriginRules.toList(),
|
"allowedOriginRules": _macosParams.allowedOriginRules.toList(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,14 +147,14 @@ class MacOSJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy {
|
|||||||
.fromPlatformJavaScriptReplyProxyCreationParams(params),
|
.fromPlatformJavaScriptReplyProxyCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
MacOSWebMessageListener get _iosWebMessageListener =>
|
MacOSWebMessageListener get _macosWebMessageListener =>
|
||||||
params.webMessageListener as MacOSWebMessageListener;
|
params.webMessageListener as MacOSWebMessageListener;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> postMessage(WebMessage message) async {
|
Future<void> postMessage(WebMessage message) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
args.putIfAbsent('message', () => message.toMap());
|
args.putIfAbsent('message', () => message.toMap());
|
||||||
await _iosWebMessageListener.channel?.invokeMethod('postMessage', args);
|
await _macosWebMessageListener.channel?.invokeMethod('postMessage', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -144,7 +144,8 @@ class PlatformAssetsPathHandlerCreationParams
|
|||||||
///Developers should ensure that asset files are named using standard file extensions.
|
///Developers should ensure that asset files are named using standard file extensions.
|
||||||
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformAssetsPathHandler extends PlatformInterface implements PlatformPathHandler {
|
abstract class PlatformAssetsPathHandler extends PlatformInterface
|
||||||
|
implements PlatformPathHandler {
|
||||||
/// Creates a new [PlatformAssetsPathHandler]
|
/// Creates a new [PlatformAssetsPathHandler]
|
||||||
factory PlatformAssetsPathHandler(
|
factory PlatformAssetsPathHandler(
|
||||||
PlatformAssetsPathHandlerCreationParams params) {
|
PlatformAssetsPathHandlerCreationParams params) {
|
||||||
@ -216,7 +217,8 @@ class PlatformResourcesPathHandlerCreationParams
|
|||||||
///Developers should ensure that asset files are named using standard file extensions.
|
///Developers should ensure that asset files are named using standard file extensions.
|
||||||
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformResourcesPathHandler extends PlatformInterface implements PlatformPathHandler {
|
abstract class PlatformResourcesPathHandler extends PlatformInterface
|
||||||
|
implements PlatformPathHandler {
|
||||||
/// Creates a new [PlatformResourcesPathHandler]
|
/// Creates a new [PlatformResourcesPathHandler]
|
||||||
factory PlatformResourcesPathHandler(
|
factory PlatformResourcesPathHandler(
|
||||||
PlatformResourcesPathHandlerCreationParams params) {
|
PlatformResourcesPathHandlerCreationParams params) {
|
||||||
@ -239,7 +241,8 @@ abstract class PlatformResourcesPathHandler extends PlatformInterface implements
|
|||||||
/// 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
|
||||||
PlatformResourcesPathHandler.implementation(this.params) : super(token: _token);
|
PlatformResourcesPathHandler.implementation(this.params)
|
||||||
|
: super(token: _token);
|
||||||
|
|
||||||
static final Object _token = Object();
|
static final Object _token = Object();
|
||||||
|
|
||||||
@ -299,7 +302,8 @@ class PlatformInternalStoragePathHandlerCreationParams
|
|||||||
///Developers should ensure that asset files are named using standard file extensions.
|
///Developers should ensure that asset files are named using standard file extensions.
|
||||||
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformInternalStoragePathHandler extends PlatformInterface implements PlatformPathHandler {
|
abstract class PlatformInternalStoragePathHandler extends PlatformInterface
|
||||||
|
implements PlatformPathHandler {
|
||||||
/// Creates a new [PlatformResourcesPathHandler]
|
/// Creates a new [PlatformResourcesPathHandler]
|
||||||
factory PlatformInternalStoragePathHandler(
|
factory PlatformInternalStoragePathHandler(
|
||||||
PlatformInternalStoragePathHandlerCreationParams params) {
|
PlatformInternalStoragePathHandlerCreationParams params) {
|
||||||
@ -322,7 +326,8 @@ abstract class PlatformInternalStoragePathHandler extends PlatformInterface impl
|
|||||||
/// 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
|
||||||
PlatformInternalStoragePathHandler.implementation(this.params) : super(token: _token);
|
PlatformInternalStoragePathHandler.implementation(this.params)
|
||||||
|
: super(token: _token);
|
||||||
|
|
||||||
static final Object _token = Object();
|
static final Object _token = Object();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user