created flutter_inappwebview_macos

This commit is contained in:
Lorenzo Pichilli 2023-11-27 09:46:37 +01:00
parent b1e7a5b3df
commit e0c03b0891
203 changed files with 8062 additions and 54 deletions

View File

@ -5,7 +5,7 @@
import FlutterMacOS
import Foundation
import flutter_inappwebview
import flutter_inappwebview_macos
import path_provider_foundation
import url_launcher_macos

View File

@ -0,0 +1,5 @@
targets:
$default:
sources:
exclude:
- example/**.dart

View File

@ -0,0 +1,5 @@
targets:
$default:
sources:
exclude:
- example/**.dart

View File

@ -1923,13 +1923,6 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
args.putIfAbsent('source', () => source);
args.putIfAbsent('contentWorld', () => contentWorld?.toMap());
var data = await channel?.invokeMethod('evaluateJavascript', args);
if (data != null && (Util.isAndroid || Util.isWeb)) {
try {
// try to json decode the data coming from JavaScript
// otherwise return it as it is.
data = json.decode(data);
} catch (e) {}
}
return data;
}
@ -2185,9 +2178,6 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
{required double zoomFactor,
@Deprecated('Use animated instead') bool? iosAnimated,
bool animated = false}) async {
assert(!Util.isAndroid ||
(Util.isAndroid && zoomFactor > 0.01 && zoomFactor <= 100.0));
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('zoomFactor', () => zoomFactor);
args.putIfAbsent('animated', () => iosAnimated ?? animated);
@ -2398,7 +2388,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
@override
Future<void> addUserScript({required UserScript userScript}) async {
assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS));
assert(webviewParams?.windowId == null);
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('userScript', () => userScript.toMap());
@ -2411,7 +2401,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
@override
Future<void> addUserScripts({required List<UserScript> userScripts}) async {
assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS));
assert(webviewParams?.windowId == null);
for (var i = 0; i < userScripts.length; i++) {
await addUserScript(userScript: userScripts[i]);
@ -2420,7 +2410,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
@override
Future<bool> removeUserScript({required UserScript userScript}) async {
assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS));
assert(webviewParams?.windowId == null);
var index = _userScripts[userScript.injectionTime]?.indexOf(userScript);
if (index == null || index == -1) {
@ -2438,7 +2428,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
@override
Future<void> removeUserScriptsByGroupName({required String groupName}) async {
assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS));
assert(webviewParams?.windowId == null);
final List<UserScript> userScriptsAtDocumentStart = List.from(
_userScripts[UserScriptInjectionTime.AT_DOCUMENT_START] ?? []);
@ -2464,7 +2454,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
@override
Future<void> removeUserScripts(
{required List<UserScript> userScripts}) async {
assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS));
assert(webviewParams?.windowId == null);
for (final userScript in userScripts) {
await removeUserScript(userScript: userScript);
@ -2473,7 +2463,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
@override
Future<void> removeAllUserScripts() async {
assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS));
assert(webviewParams?.windowId == null);
_userScripts[UserScriptInjectionTime.AT_DOCUMENT_START]?.clear();
_userScripts[UserScriptInjectionTime.AT_DOCUMENT_END]?.clear();
@ -2501,9 +2491,6 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
if (data == null) {
return null;
}
if (Util.isAndroid) {
data = json.decode(data);
}
return CallAsyncJavaScriptResult(
value: data["value"], error: data["error"]);
}
@ -2512,13 +2499,9 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
Future<String?> saveWebArchive(
{required String filePath, bool autoname = false}) async {
if (!autoname) {
if (Util.isAndroid) {
assert(filePath.endsWith("." + WebArchiveFormat.MHT.toNativeValue()));
} else if (Util.isIOS || Util.isMacOS) {
assert(filePath
.endsWith("." + WebArchiveFormat.WEBARCHIVE.toNativeValue()));
}
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("filePath", () => filePath);

View File

@ -22,29 +22,7 @@ class IOSWebAuthenticationSessionCreationParams
}
}
///A session that an app uses to authenticate a user through a web service.
///
///It is implemented using [ASWebAuthenticationSession](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession) on iOS 12.0+ and MacOS 10.15+
///and [SFAuthenticationSession](https://developer.apple.com/documentation/safariservices/sfauthenticationsession) on iOS 11.0.
///
///Use an [IOSWebAuthenticationSession] instance to authenticate a user through a web service, including one run by a third party.
///Initialize the session with a URL that points to the authentication webpage.
///A browser loads and displays the page, from which the user can authenticate.
///In iOS, the browser is a secure, embedded web view.
///In macOS, the system opens the users default browser if it supports web authentication sessions, or Safari otherwise.
///
///On completion, the service sends a callback URL to the session with an authentication token, and the session passes this URL back to the app through a completion handler.
///[IOSWebAuthenticationSession] ensures that only the calling apps session receives the authentication callback, even when more than one app registers the same callback URL scheme.
///
///**NOTE**: Remember to dispose it when you don't need it anymore.
///
///**NOTE for iOS**: Available only on iOS 11.0+.
///
///**NOTE for MacOS**: Available only on MacOS 10.15+.
///
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession}
class IOSWebAuthenticationSession extends PlatformWebAuthenticationSession
with ChannelController {
/// Constructs a [IOSWebAuthenticationSession].

View File

@ -42,8 +42,8 @@ flutter:
# This is required for using `dart:ffi`.
# All these are used by the tooling to maintain consistency when
# adding or updating assets for this project.
implements: flutter_inappwebview
plugin:
implements: flutter_inappwebview
platforms:
ios:
pluginClass: InAppWebViewFlutterPlugin

30
flutter_inappwebview_macos/.gitignore vendored Normal file
View File

@ -0,0 +1,30 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/

View File

@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: "6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e"
channel: "stable"
project_type: plugin
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e
base_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e
- platform: macos
create_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e
base_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

View File

@ -0,0 +1,3 @@
## 0.0.1
* TODO: Describe initial release.

View File

@ -0,0 +1 @@
TODO: Add your license here.

View File

@ -0,0 +1,15 @@
# flutter_inappwebview_macos
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
For help getting started with Flutter development, view the
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

View File

@ -0,0 +1,13 @@
include: package:flutter_lints/flutter.yaml
linter:
rules:
constant_identifier_names: ignore
deprecated_member_use_from_same_package: ignore
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
analyzer:
errors:
deprecated_member_use: ignore
deprecated_member_use_from_same_package: ignore

View File

@ -0,0 +1,5 @@
targets:
$default:
sources:
exclude:
- example/**.dart

View File

@ -0,0 +1,44 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

View File

@ -0,0 +1,16 @@
# flutter_inappwebview_macos_example
Demonstrates how to use the flutter_inappwebview_macos plugin.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

View File

@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -0,0 +1,7 @@
# Flutter-related
**/Flutter/ephemeral/
**/Pods/
# Xcode-related
**/dgph
**/xcuserdata/

View File

@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@ -0,0 +1,12 @@
//
// Generated file. Do not edit.
//
import FlutterMacOS
import Foundation
import flutter_inappwebview_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
}

View File

@ -0,0 +1,43 @@
platform :osx, '10.14'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end

View File

@ -0,0 +1,695 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objects = {
/* Begin PBXAggregateTarget section */
33CC111A2044C6BA0003C045 /* Flutter Assemble */ = {
isa = PBXAggregateTarget;
buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */;
buildPhases = (
33CC111E2044C6BF0003C045 /* ShellScript */,
);
dependencies = (
);
name = "Flutter Assemble";
productName = FLX;
};
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; };
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 33CC10EC2044A3C60003C045;
remoteInfo = Runner;
};
33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 33CC111A2044C6BA0003C045;
remoteInfo = FLX;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
33CC110E2044A8840003C045 /* Bundle Framework */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Bundle Framework";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
33CC10ED2044A3C60003C045 /* flutter_inappwebview_macos_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "flutter_inappwebview_macos_example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = "<group>"; };
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = "<group>"; };
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
331C80D2294CF70F00263BE5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
33CC10EA2044A3C60003C045 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
331C80D6294CF71000263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
331C80D7294CF71000263BE5 /* RunnerTests.swift */,
);
path = RunnerTests;
sourceTree = "<group>";
};
33BA886A226E78AF003329D5 /* Configs */ = {
isa = PBXGroup;
children = (
33E5194F232828860026EE4D /* AppInfo.xcconfig */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
333000ED22D3DE5D00554162 /* Warnings.xcconfig */,
);
path = Configs;
sourceTree = "<group>";
};
33CC10E42044A3C60003C045 = {
isa = PBXGroup;
children = (
33FAB671232836740065AC1E /* Runner */,
33CEB47122A05771004F2AC0 /* Flutter */,
331C80D6294CF71000263BE5 /* RunnerTests */,
33CC10EE2044A3C60003C045 /* Products */,
D73912EC22F37F3D000D13A0 /* Frameworks */,
);
sourceTree = "<group>";
};
33CC10EE2044A3C60003C045 /* Products */ = {
isa = PBXGroup;
children = (
33CC10ED2044A3C60003C045 /* flutter_inappwebview_macos_example.app */,
331C80D5294CF71000263BE5 /* RunnerTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
33CC11242044D66E0003C045 /* Resources */ = {
isa = PBXGroup;
children = (
33CC10F22044A3C60003C045 /* Assets.xcassets */,
33CC10F42044A3C60003C045 /* MainMenu.xib */,
33CC10F72044A3C60003C045 /* Info.plist */,
);
name = Resources;
path = ..;
sourceTree = "<group>";
};
33CEB47122A05771004F2AC0 /* Flutter */ = {
isa = PBXGroup;
children = (
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */,
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
);
path = Flutter;
sourceTree = "<group>";
};
33FAB671232836740065AC1E /* Runner */ = {
isa = PBXGroup;
children = (
33CC10F02044A3C60003C045 /* AppDelegate.swift */,
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
33E51913231747F40026EE4D /* DebugProfile.entitlements */,
33E51914231749380026EE4D /* Release.entitlements */,
33CC11242044D66E0003C045 /* Resources */,
33BA886A226E78AF003329D5 /* Configs */,
);
path = Runner;
sourceTree = "<group>";
};
D73912EC22F37F3D000D13A0 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
331C80D4294CF70F00263BE5 /* RunnerTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
331C80D1294CF70F00263BE5 /* Sources */,
331C80D2294CF70F00263BE5 /* Frameworks */,
331C80D3294CF70F00263BE5 /* Resources */,
);
buildRules = (
);
dependencies = (
331C80DA294CF71000263BE5 /* PBXTargetDependency */,
);
name = RunnerTests;
productName = RunnerTests;
productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
33CC10EC2044A3C60003C045 /* Runner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
33CC10E92044A3C60003C045 /* Sources */,
33CC10EA2044A3C60003C045 /* Frameworks */,
33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */,
);
buildRules = (
);
dependencies = (
33CC11202044C79F0003C045 /* PBXTargetDependency */,
);
name = Runner;
productName = Runner;
productReference = 33CC10ED2044A3C60003C045 /* flutter_inappwebview_macos_example.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
33CC10E52044A3C60003C045 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
CreatedOnToolsVersion = 14.0;
TestTargetID = 33CC10EC2044A3C60003C045;
};
33CC10EC2044A3C60003C045 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1100;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.Sandbox = {
enabled = 1;
};
};
};
33CC111A2044C6BA0003C045 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Manual;
};
};
};
buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 33CC10E42044A3C60003C045;
productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
33CC10EC2044A3C60003C045 /* Runner */,
331C80D4294CF70F00263BE5 /* RunnerTests */,
33CC111A2044C6BA0003C045 /* Flutter Assemble */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
331C80D3294CF70F00263BE5 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
33CC10EB2044A3C60003C045 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
};
33CC111E2044C6BF0003C045 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
Flutter/ephemeral/FlutterInputs.xcfilelist,
);
inputPaths = (
Flutter/ephemeral/tripwire,
);
outputFileListPaths = (
Flutter/ephemeral/FlutterOutputs.xcfilelist,
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
331C80D1294CF70F00263BE5 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
33CC10E92044A3C60003C045 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
331C80DA294CF71000263BE5 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 33CC10EC2044A3C60003C045 /* Runner */;
targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */;
};
33CC11202044C79F0003C045 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */;
targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
33CC10F42044A3C60003C045 /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
33CC10F52044A3C60003C045 /* Base */,
);
name = MainMenu.xib;
path = Runner;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
331C80DB294CF71000263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pichillilorenzo.flutterInappwebviewMacosExample.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_inappwebview_macos_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_inappwebview_macos_example";
};
name = Debug;
};
331C80DC294CF71000263BE5 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pichillilorenzo.flutterInappwebviewMacosExample.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_inappwebview_macos_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_inappwebview_macos_example";
};
name = Release;
};
331C80DD294CF71000263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pichillilorenzo.flutterInappwebviewMacosExample.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_inappwebview_macos_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_inappwebview_macos_example";
};
name = Profile;
};
338D0CE9231458BD00FA5F75 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Profile;
};
338D0CEA231458BD00FA5F75 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Profile;
};
338D0CEB231458BD00FA5F75 /* Profile */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Manual;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Profile;
};
33CC10F92044A3C60003C045 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
33CC10FA2044A3C60003C045 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
};
33CC10FC2044A3C60003C045 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
33CC10FD2044A3C60003C045 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Release;
};
33CC111C2044C6BA0003C045 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Manual;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
33CC111D2044C6BA0003C045 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
331C80DB294CF71000263BE5 /* Debug */,
331C80DC294CF71000263BE5 /* Release */,
331C80DD294CF71000263BE5 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33CC10F92044A3C60003C045 /* Debug */,
33CC10FA2044A3C60003C045 /* Release */,
338D0CE9231458BD00FA5F75 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33CC10FC2044A3C60003C045 /* Debug */,
33CC10FD2044A3C60003C045 /* Release */,
338D0CEA231458BD00FA5F75 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33CC111C2044C6BA0003C045 /* Debug */,
33CC111D2044C6BA0003C045 /* Release */,
338D0CEB231458BD00FA5F75 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 33CC10E52044A3C60003C045 /* Project object */;
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "flutter_inappwebview_macos_example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "flutter_inappwebview_macos_example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "331C80D4294CF70F00263BE5"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "flutter_inappwebview_macos_example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "flutter_inappwebview_macos_example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,9 @@
import Cocoa
import FlutterMacOS
@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
}

View File

@ -0,0 +1,68 @@
{
"images" : [
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "app_icon_16.png",
"scale" : "1x"
},
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "app_icon_32.png",
"scale" : "2x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "app_icon_32.png",
"scale" : "1x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "app_icon_64.png",
"scale" : "2x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "app_icon_128.png",
"scale" : "1x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "app_icon_256.png",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "app_icon_256.png",
"scale" : "1x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "app_icon_512.png",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "app_icon_512.png",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "app_icon_1024.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,343 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Runner" customModuleProvider="target">
<connections>
<outlet property="applicationMenu" destination="uQy-DD-JDr" id="XBo-yE-nKs"/>
<outlet property="mainFlutterWindow" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="APP_NAME" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="APP_NAME" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About APP_NAME" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide APP_NAME" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit APP_NAME" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Edit" id="5QF-Oa-p0T">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Edit" id="W48-6f-4Dl">
<items>
<menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
<connections>
<action selector="undo:" target="-1" id="M6e-cu-g7V"/>
</connections>
</menuItem>
<menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
<connections>
<action selector="redo:" target="-1" id="oIA-Rs-6OD"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
<menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
<connections>
<action selector="cut:" target="-1" id="YJe-68-I9s"/>
</connections>
</menuItem>
<menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
<connections>
<action selector="copy:" target="-1" id="G1f-GL-Joy"/>
</connections>
</menuItem>
<menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
<connections>
<action selector="paste:" target="-1" id="UvS-8e-Qdg"/>
</connections>
</menuItem>
<menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/>
</connections>
</menuItem>
<menuItem title="Delete" id="pa3-QI-u2k">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="delete:" target="-1" id="0Mk-Ml-PaM"/>
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
<connections>
<action selector="selectAll:" target="-1" id="VNm-Mi-diN"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
<menuItem title="Find" id="4EN-yA-p0u">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Find" id="1b7-l0-nxx">
<items>
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
<connections>
<action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
</connections>
</menuItem>
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
</connections>
</menuItem>
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
<connections>
<action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
</connections>
</menuItem>
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
<connections>
<action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
</connections>
</menuItem>
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
<connections>
<action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
</connections>
</menuItem>
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
<connections>
<action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
<items>
<menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
<connections>
<action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/>
</connections>
</menuItem>
<menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
<connections>
<action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
<menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/>
</connections>
</menuItem>
<menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/>
</connections>
</menuItem>
<menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Substitutions" id="9ic-FL-obx">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
<items>
<menuItem title="Show Substitutions" id="z6F-FW-3nz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
<menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/>
</connections>
</menuItem>
<menuItem title="Smart Quotes" id="hQb-2v-fYv">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/>
</connections>
</menuItem>
<menuItem title="Smart Dashes" id="rgM-f4-ycn">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/>
</connections>
</menuItem>
<menuItem title="Smart Links" id="cwL-P1-jid">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/>
</connections>
</menuItem>
<menuItem title="Data Detectors" id="tRr-pd-1PS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/>
</connections>
</menuItem>
<menuItem title="Text Replacement" id="HFQ-gK-NFA">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Transformations" id="2oI-Rn-ZJC">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Transformations" id="c8a-y6-VQd">
<items>
<menuItem title="Make Upper Case" id="vmV-6d-7jI">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/>
</connections>
</menuItem>
<menuItem title="Make Lower Case" id="d9M-CD-aMd">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/>
</connections>
</menuItem>
<menuItem title="Capitalize" id="UEZ-Bs-lqG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Speech" id="xrE-MZ-jX0">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Speech" id="3rS-ZA-NoH">
<items>
<menuItem title="Start Speaking" id="Ynk-f8-cLZ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/>
</connections>
</menuItem>
<menuItem title="Stop Speaking" id="Oyz-dy-DGm">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="H8h-7b-M4v">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleFullScreen:" target="-1" id="dU3-MA-1Rq"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="EPT-qC-fAb">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="rJ0-wn-3NY"/>
</menuItem>
</items>
<point key="canvasLocation" x="142" y="-258"/>
</menu>
<window title="APP_NAME" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="MainFlutterWindow" customModule="Runner" customModuleProvider="target">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="335" y="390" width="800" height="600"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1577"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</window>
</objects>
</document>

View File

@ -0,0 +1,14 @@
// Application-level settings for the Runner target.
//
// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
// future. If not, the values below would default to using the project name when this becomes a
// 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = flutter_inappwebview_macos_example
// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = com.pichillilorenzo.flutterInappwebviewMacosExample
// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2023 com.pichillilorenzo. All rights reserved.

View File

@ -0,0 +1,2 @@
#include "../../Flutter/Flutter-Debug.xcconfig"
#include "Warnings.xcconfig"

View File

@ -0,0 +1,2 @@
#include "../../Flutter/Flutter-Release.xcconfig"
#include "Warnings.xcconfig"

View File

@ -0,0 +1,13 @@
WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
GCC_WARN_UNDECLARED_SELECTOR = YES
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_PRAGMA_PACK = YES
CLANG_WARN_STRICT_PROTOTYPES = YES
CLANG_WARN_COMMA = YES
GCC_WARN_STRICT_SELECTOR_MATCH = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
GCC_WARN_SHADOW = YES
CLANG_WARN_UNREACHABLE_CODE = YES

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>$(PRODUCT_COPYRIGHT)</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,15 @@
import Cocoa
import FlutterMacOS
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
super.awakeFromNib()
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,27 @@
import FlutterMacOS
import Cocoa
import XCTest
@testable import flutter_inappwebview_macos
// This demonstrates a simple unit test of the Swift portion of this plugin's implementation.
//
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
class RunnerTests: XCTestCase {
func testGetPlatformVersion() {
let plugin = FlutterInappwebviewMacosPlugin()
let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: [])
let resultExpectation = expectation(description: "result block must be called.")
plugin.handle(call) { result in
XCTAssertEqual(result as! String,
"macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
resultExpectation.fulfill()
}
waitForExpectations(timeout: 1)
}
}

View File

@ -0,0 +1,282 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.17.2"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
url: "https://pub.dev"
source: hosted
version: "1.0.6"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
file:
dependency: transitive
description:
name: file
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_driver:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_inappwebview_internal_annotations:
dependency: transitive
description:
name: flutter_inappwebview_internal_annotations
sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
flutter_inappwebview_macos:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.0.0"
flutter_inappwebview_platform_interface:
dependency: transitive
description:
path: "../../flutter_inappwebview_platform_interface"
relative: true
source: path
version: "1.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
url: "https://pub.dev"
source: hosted
version: "2.0.3"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
integration_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
lints:
dependency: transitive
description:
name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
platform:
dependency: transitive
description:
name: platform
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
url: "https://pub.dev"
source: hosted
version: "2.1.7"
process:
dependency: transitive
description:
name: process
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
url: "https://pub.dev"
source: hosted
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.dev"
source: hosted
version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
sync_http:
dependency: transitive
description:
name: sync_http
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: c620a6f783fa22436da68e42db7ebbf18b8c44b9a46ab911f666ff09ffd9153f
url: "https://pub.dev"
source: hosted
version: "11.7.1"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
sdks:
dart: ">=3.1.4 <4.0.0"
flutter: ">=3.0.0"

View File

@ -0,0 +1,85 @@
name: flutter_inappwebview_macos_example
description: Demonstrates how to use the flutter_inappwebview_macos plugin.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment:
sdk: '>=3.1.4 <4.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
flutter_inappwebview_macos:
# When depending on this package from a real application you should use:
# flutter_inappwebview_macos: ^x.y.z
# See https://dart.dev/tools/pub/dependencies#version-constraints
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ../
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dev_dependencies:
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

View File

@ -0,0 +1,3 @@
library flutter_inappwebview_macos;
export 'src/main.dart';

View File

@ -0,0 +1,439 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import 'in_app_webview/headless_in_app_webview.dart';
import 'platform_util.dart';
/// Object specifying creation parameters for creating a [MacOSCookieManager].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformCookieManagerCreationParams] for
/// more information.
@immutable
class MacOSCookieManagerCreationParams
extends PlatformCookieManagerCreationParams {
/// Creates a new [MacOSCookieManagerCreationParams] instance.
const MacOSCookieManagerCreationParams(
// This parameter prevents breaking changes later.
// ignore: avoid_unused_constructor_parameters
PlatformCookieManagerCreationParams params,
) : super();
/// Creates a [MacOSCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams].
factory MacOSCookieManagerCreationParams.fromPlatformCookieManagerCreationParams(
PlatformCookieManagerCreationParams params) {
return MacOSCookieManagerCreationParams(params);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager}
class MacOSCookieManager extends PlatformCookieManager
with ChannelController {
/// Creates a new [MacOSCookieManager].
MacOSCookieManager(PlatformCookieManagerCreationParams params)
: super.implementation(
params is MacOSCookieManagerCreationParams
? params
: MacOSCookieManagerCreationParams
.fromPlatformCookieManagerCreationParams(params),
) {
channel = const MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_cookiemanager');
handler = handleMethod;
initMethodCallHandler();
}
static MacOSCookieManager? _instance;
///Gets the [MacOSCookieManager] shared instance.
static MacOSCookieManager instance() {
return (_instance != null) ? _instance! : _init();
}
static MacOSCookieManager _init() {
_instance = MacOSCookieManager(MacOSCookieManagerCreationParams(
const PlatformCookieManagerCreationParams()));
return _instance!;
}
Future<dynamic> _handleMethod(MethodCall call) async {}
@override
Future<bool> setCookie(
{required WebUri url,
required String name,
required String value,
String path = "/",
String? domain,
int? expiresDate,
int? maxAge,
bool? isSecure,
bool? isHttpOnly,
HTTPCookieSameSitePolicy? sameSite,
@Deprecated("Use webViewController instead")
PlatformInAppWebViewController? iosBelow11WebViewController,
PlatformInAppWebViewController? webViewController}) async {
webViewController = webViewController ?? iosBelow11WebViewController;
assert(url.toString().isNotEmpty);
assert(name.isNotEmpty);
assert(value.isNotEmpty);
assert(path.isNotEmpty);
if (await _shouldUseJavascript()) {
await _setCookieWithJavaScript(
url: url,
name: name,
value: value,
domain: domain,
path: path,
expiresDate: expiresDate,
maxAge: maxAge,
isSecure: isSecure,
sameSite: sameSite,
webViewController: webViewController);
return true;
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString());
args.putIfAbsent('name', () => name);
args.putIfAbsent('value', () => value);
args.putIfAbsent('domain', () => domain);
args.putIfAbsent('path', () => path);
args.putIfAbsent('expiresDate', () => expiresDate?.toString());
args.putIfAbsent('maxAge', () => maxAge);
args.putIfAbsent('isSecure', () => isSecure);
args.putIfAbsent('isHttpOnly', () => isHttpOnly);
args.putIfAbsent('sameSite', () => sameSite?.toNativeValue());
return await channel?.invokeMethod<bool>('setCookie', args) ?? false;
}
Future<void> _setCookieWithJavaScript(
{required WebUri url,
required String name,
required String value,
String path = "/",
String? domain,
int? expiresDate,
int? maxAge,
bool? isSecure,
HTTPCookieSameSitePolicy? sameSite,
PlatformInAppWebViewController? webViewController}) async {
var cookieValue = name + "=" + value + "; Path=" + path;
if (domain != null) cookieValue += "; Domain=" + domain;
if (expiresDate != null)
cookieValue += "; Expires=" + await _getCookieExpirationDate(expiresDate);
if (maxAge != null) cookieValue += "; Max-Age=" + maxAge.toString();
if (isSecure != null && isSecure) cookieValue += "; Secure";
if (sameSite != null)
cookieValue += "; SameSite=" + sameSite.toNativeValue();
cookieValue += ";";
if (webViewController != null) {
final javaScriptEnabled =
(await webViewController.getSettings())?.javaScriptEnabled ?? false;
if (javaScriptEnabled) {
await webViewController.evaluateJavascript(
source: 'document.cookie="$cookieValue"');
return;
}
}
final setCookieCompleter = Completer<void>();
final headlessWebView =
MacOSHeadlessInAppWebView(MacOSHeadlessInAppWebViewCreationParams(
initialUrlRequest: URLRequest(url: url),
onLoadStop: (controller, url) async {
await controller.evaluateJavascript(
source: 'document.cookie="$cookieValue"');
setCookieCompleter.complete();
}));
await headlessWebView.run();
await setCookieCompleter.future;
await headlessWebView.dispose();
}
@override
Future<List<Cookie>> getCookies(
{required WebUri url,
@Deprecated("Use webViewController instead")
PlatformInAppWebViewController? iosBelow11WebViewController,
PlatformInAppWebViewController? webViewController}) async {
assert(url.toString().isNotEmpty);
webViewController = webViewController ?? iosBelow11WebViewController;
if (await _shouldUseJavascript()) {
return await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
}
List<Cookie> cookies = [];
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString());
List<dynamic> cookieListMap =
await channel?.invokeMethod<List>('getCookies', args) ?? [];
cookieListMap = cookieListMap.cast<Map<dynamic, dynamic>>();
cookieListMap.forEach((cookieMap) {
cookies.add(Cookie(
name: cookieMap["name"],
value: cookieMap["value"],
expiresDate: cookieMap["expiresDate"],
isSessionOnly: cookieMap["isSessionOnly"],
domain: cookieMap["domain"],
sameSite:
HTTPCookieSameSitePolicy.fromNativeValue(cookieMap["sameSite"]),
isSecure: cookieMap["isSecure"],
isHttpOnly: cookieMap["isHttpOnly"],
path: cookieMap["path"]));
});
return cookies;
}
Future<List<Cookie>> _getCookiesWithJavaScript(
{required WebUri url,
PlatformInAppWebViewController? webViewController}) async {
assert(url.toString().isNotEmpty);
List<Cookie> cookies = [];
if (webViewController != null) {
final javaScriptEnabled =
(await webViewController.getSettings())?.javaScriptEnabled ?? false;
if (javaScriptEnabled) {
List<String> documentCookies = (await webViewController
.evaluateJavascript(source: 'document.cookie') as String)
.split(';')
.map((documentCookie) => documentCookie.trim())
.toList();
documentCookies.forEach((documentCookie) {
List<String> cookie = documentCookie.split('=');
if (cookie.length > 1) {
cookies.add(Cookie(
name: cookie[0],
value: cookie[1],
));
}
});
return cookies;
}
}
final pageLoaded = Completer<void>();
final headlessWebView =
MacOSHeadlessInAppWebView(MacOSHeadlessInAppWebViewCreationParams(
initialUrlRequest: URLRequest(url: url),
onLoadStop: (controller, url) async {
pageLoaded.complete();
},
));
await headlessWebView.run();
await pageLoaded.future;
List<String> documentCookies = (await headlessWebView.webViewController!
.evaluateJavascript(source: 'document.cookie') as String)
.split(';')
.map((documentCookie) => documentCookie.trim())
.toList();
documentCookies.forEach((documentCookie) {
List<String> cookie = documentCookie.split('=');
if (cookie.length > 1) {
cookies.add(Cookie(
name: cookie[0],
value: cookie[1],
));
}
});
await headlessWebView.dispose();
return cookies;
}
@override
Future<Cookie?> getCookie(
{required WebUri url,
required String name,
@Deprecated("Use webViewController instead")
PlatformInAppWebViewController? iosBelow11WebViewController,
PlatformInAppWebViewController? webViewController}) async {
assert(url.toString().isNotEmpty);
assert(name.isNotEmpty);
webViewController = webViewController ?? iosBelow11WebViewController;
if (await _shouldUseJavascript()) {
List<Cookie> cookies = await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
return cookies
.cast<Cookie?>()
.firstWhere((cookie) => cookie!.name == name, orElse: () => null);
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString());
List<dynamic> cookies =
await channel?.invokeMethod<List>('getCookies', args) ?? [];
cookies = cookies.cast<Map<dynamic, dynamic>>();
for (var i = 0; i < cookies.length; i++) {
cookies[i] = cookies[i].cast<String, dynamic>();
if (cookies[i]["name"] == name)
return Cookie(
name: cookies[i]["name"],
value: cookies[i]["value"],
expiresDate: cookies[i]["expiresDate"],
isSessionOnly: cookies[i]["isSessionOnly"],
domain: cookies[i]["domain"],
sameSite: HTTPCookieSameSitePolicy.fromNativeValue(
cookies[i]["sameSite"]),
isSecure: cookies[i]["isSecure"],
isHttpOnly: cookies[i]["isHttpOnly"],
path: cookies[i]["path"]);
}
return null;
}
@override
Future<void> deleteCookie(
{required WebUri url,
required String name,
String path = "/",
String? domain,
@Deprecated("Use webViewController instead")
PlatformInAppWebViewController? iosBelow11WebViewController,
PlatformInAppWebViewController? webViewController}) async {
assert(url.toString().isNotEmpty);
assert(name.isNotEmpty);
webViewController = webViewController ?? iosBelow11WebViewController;
if (await _shouldUseJavascript()) {
await _setCookieWithJavaScript(
url: url,
name: name,
value: "",
path: path,
domain: domain,
maxAge: -1,
webViewController: webViewController);
return;
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString());
args.putIfAbsent('name', () => name);
args.putIfAbsent('domain', () => domain);
args.putIfAbsent('path', () => path);
await channel?.invokeMethod('deleteCookie', args);
}
@override
Future<void> deleteCookies(
{required WebUri url,
String path = "/",
String? domain,
@Deprecated("Use webViewController instead")
PlatformInAppWebViewController? iosBelow11WebViewController,
PlatformInAppWebViewController? webViewController}) async {
assert(url.toString().isNotEmpty);
webViewController = webViewController ?? iosBelow11WebViewController;
if (await _shouldUseJavascript()) {
List<Cookie> cookies = await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
for (var i = 0; i < cookies.length; i++) {
await _setCookieWithJavaScript(
url: url,
name: cookies[i].name,
value: "",
path: path,
domain: domain,
maxAge: -1,
webViewController: webViewController);
}
return;
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString());
args.putIfAbsent('domain', () => domain);
args.putIfAbsent('path', () => path);
await channel?.invokeMethod('deleteCookies', args);
}
@override
Future<void> deleteAllCookies() async {
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('deleteAllCookies', args);
}
@override
Future<List<Cookie>> getAllCookies() async {
List<Cookie> cookies = [];
Map<String, dynamic> args = <String, dynamic>{};
List<dynamic> cookieListMap =
await channel?.invokeMethod<List>('getAllCookies', args) ?? [];
cookieListMap = cookieListMap.cast<Map<dynamic, dynamic>>();
cookieListMap.forEach((cookieMap) {
cookies.add(Cookie(
name: cookieMap["name"],
value: cookieMap["value"],
expiresDate: cookieMap["expiresDate"],
isSessionOnly: cookieMap["isSessionOnly"],
domain: cookieMap["domain"],
sameSite:
HTTPCookieSameSitePolicy.fromNativeValue(cookieMap["sameSite"]),
isSecure: cookieMap["isSecure"],
isHttpOnly: cookieMap["isHttpOnly"],
path: cookieMap["path"]));
});
return cookies;
}
Future<String> _getCookieExpirationDate(int expiresDate) async {
var platformUtil = PlatformUtil.instance();
var dateTime = DateTime.fromMillisecondsSinceEpoch(expiresDate).toUtc();
return !kIsWeb
? await platformUtil.formatDate(
date: dateTime,
format: 'EEE, dd MMM yyyy hh:mm:ss z',
locale: 'en_US',
timezone: 'GMT')
: await platformUtil.getWebCookieExpirationDate(date: dateTime);
}
Future<bool> _shouldUseJavascript() async {
if (Util.isMacOS || Util.isMacOS) {
final platformUtil = PlatformUtil.instance();
final systemVersion = await platformUtil.getSystemVersion();
return Util.isMacOS
? systemVersion.compareTo("11") == -1
: systemVersion.compareTo("10.13") == -1;
}
return false;
}
@override
void dispose() {
// empty
}
}
extension InternalCookieManager on MacOSCookieManager {
get handleMethod => _handleMethod;
}

View File

@ -0,0 +1,125 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
/// Object specifying creation parameters for creating a [MacOSFindInteractionController].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformFindInteractionControllerCreationParams] for
/// more information.
@immutable
class MacOSFindInteractionControllerCreationParams
extends PlatformFindInteractionControllerCreationParams {
/// Creates a new [MacOSFindInteractionControllerCreationParams] instance.
const MacOSFindInteractionControllerCreationParams(
{super.onFindResultReceived});
/// Creates a [MacOSFindInteractionControllerCreationParams] instance based on [PlatformFindInteractionControllerCreationParams].
factory MacOSFindInteractionControllerCreationParams.fromPlatformFindInteractionControllerCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformFindInteractionControllerCreationParams params) {
return MacOSFindInteractionControllerCreationParams(
onFindResultReceived: params.onFindResultReceived);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController}
class MacOSFindInteractionController extends PlatformFindInteractionController
with ChannelController {
/// Constructs a [MacOSFindInteractionController].
MacOSFindInteractionController(
PlatformFindInteractionControllerCreationParams params)
: super.implementation(
params is MacOSFindInteractionControllerCreationParams
? params
: MacOSFindInteractionControllerCreationParams
.fromPlatformFindInteractionControllerCreationParams(params),
);
_debugLog(String method, dynamic args) {
debugLog(
className: this.runtimeType.toString(),
debugLoggingSettings:
PlatformFindInteractionController.debugLoggingSettings,
method: method,
args: args);
}
Future<dynamic> _handleMethod(MethodCall call) async {
_debugLog(call.method, call.arguments);
switch (call.method) {
case "onFindResultReceived":
if (onFindResultReceived != null) {
int activeMatchOrdinal = call.arguments["activeMatchOrdinal"];
int numberOfMatches = call.arguments["numberOfMatches"];
bool isDoneCounting = call.arguments["isDoneCounting"];
onFindResultReceived!(
this, activeMatchOrdinal, numberOfMatches, isDoneCounting);
}
break;
default:
throw UnimplementedError("Unimplemented ${call.method} method");
}
return null;
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.findAll}
Future<void> findAll({String? find}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('find', () => find);
await channel?.invokeMethod('findAll', args);
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.findNext}
Future<void> findNext({bool forward = true}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('forward', () => forward);
await channel?.invokeMethod('findNext', args);
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.clearMatches}
Future<void> clearMatches() async {
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('clearMatches', args);
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.setSearchText}
Future<void> setSearchText(String? searchText) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('searchText', () => searchText);
await channel?.invokeMethod('setSearchText', args);
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.getSearchText}
Future<String?> getSearchText() async {
Map<String, dynamic> args = <String, dynamic>{};
return await channel?.invokeMethod<String?>('getSearchText', args);
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.getActiveFindSession}
Future<FindSession?> getActiveFindSession() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? result =
(await channel?.invokeMethod('getActiveFindSession', args))
?.cast<String, dynamic>();
return FindSession.fromMap(result);
}
///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.dispose}
@override
void dispose({bool isKeepAlive = false}) {
disposeChannel(removeMethodCallHandler: !isKeepAlive);
}
}
extension InternalFindInteractionController
on MacOSFindInteractionController {
void init(dynamic id) {
channel = MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_find_interaction_$id');
handler = _handleMethod;
initMethodCallHandler();
}
}

View File

@ -0,0 +1,2 @@
export 'find_interaction_controller.dart'
hide InternalFindInteractionController;

View File

@ -0,0 +1,155 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
/// Object specifying creation parameters for creating a [MacOSHttpAuthCredentialDatabase].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformHttpAuthCredentialDatabaseCreationParams] for
/// more information.
@immutable
class MacOSHttpAuthCredentialDatabaseCreationParams
extends PlatformHttpAuthCredentialDatabaseCreationParams {
/// Creates a new [MacOSHttpAuthCredentialDatabaseCreationParams] instance.
const MacOSHttpAuthCredentialDatabaseCreationParams(
// This parameter prevents breaking changes later.
// ignore: avoid_unused_constructor_parameters
PlatformHttpAuthCredentialDatabaseCreationParams params,
) : super();
/// Creates a [MacOSHttpAuthCredentialDatabaseCreationParams] instance based on [PlatformHttpAuthCredentialDatabaseCreationParams].
factory MacOSHttpAuthCredentialDatabaseCreationParams.fromPlatformHttpAuthCredentialDatabaseCreationParams(
PlatformHttpAuthCredentialDatabaseCreationParams params) {
return MacOSHttpAuthCredentialDatabaseCreationParams(params);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase}
class MacOSHttpAuthCredentialDatabase
extends PlatformHttpAuthCredentialDatabase with ChannelController {
/// Creates a new [MacOSHttpAuthCredentialDatabase].
MacOSHttpAuthCredentialDatabase(
PlatformHttpAuthCredentialDatabaseCreationParams params)
: super.implementation(
params is MacOSHttpAuthCredentialDatabaseCreationParams
? params
: MacOSHttpAuthCredentialDatabaseCreationParams
.fromPlatformHttpAuthCredentialDatabaseCreationParams(params),
) {
channel = const MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_credential_database');
handler = handleMethod;
initMethodCallHandler();
}
static MacOSHttpAuthCredentialDatabase? _instance;
///Gets the database shared instance.
static MacOSHttpAuthCredentialDatabase instance() {
return (_instance != null) ? _instance! : _init();
}
static MacOSHttpAuthCredentialDatabase _init() {
_instance = MacOSHttpAuthCredentialDatabase(
MacOSHttpAuthCredentialDatabaseCreationParams(
const PlatformHttpAuthCredentialDatabaseCreationParams()));
return _instance!;
}
Future<dynamic> _handleMethod(MethodCall call) async {}
@override
Future<List<URLProtectionSpaceHttpAuthCredentials>>
getAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{};
List<dynamic> allCredentials =
await channel?.invokeMethod<List>('getAllAuthCredentials', args) ?? [];
List<URLProtectionSpaceHttpAuthCredentials> result = [];
for (Map<dynamic, dynamic> map in allCredentials) {
var element = URLProtectionSpaceHttpAuthCredentials.fromMap(
map.cast<String, dynamic>());
if (element != null) {
result.add(element);
}
}
return result;
}
@override
Future<List<URLCredential>> getHttpAuthCredentials(
{required URLProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
args.putIfAbsent("realm", () => protectionSpace.realm);
args.putIfAbsent("port", () => protectionSpace.port);
List<dynamic> credentialList =
await channel?.invokeMethod<List>('getHttpAuthCredentials', args) ?? [];
List<URLCredential> credentials = [];
for (Map<dynamic, dynamic> map in credentialList) {
var credential = URLCredential.fromMap(map.cast<String, dynamic>());
if (credential != null) {
credentials.add(credential);
}
}
return credentials;
}
@override
Future<void> setHttpAuthCredential(
{required URLProtectionSpace protectionSpace,
required URLCredential credential}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
args.putIfAbsent("realm", () => protectionSpace.realm);
args.putIfAbsent("port", () => protectionSpace.port);
args.putIfAbsent("username", () => credential.username);
args.putIfAbsent("password", () => credential.password);
await channel?.invokeMethod('setHttpAuthCredential', args);
}
@override
Future<void> removeHttpAuthCredential(
{required URLProtectionSpace protectionSpace,
required URLCredential credential}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
args.putIfAbsent("realm", () => protectionSpace.realm);
args.putIfAbsent("port", () => protectionSpace.port);
args.putIfAbsent("username", () => credential.username);
args.putIfAbsent("password", () => credential.password);
await channel?.invokeMethod('removeHttpAuthCredential', args);
}
@override
Future<void> removeHttpAuthCredentials(
{required URLProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
args.putIfAbsent("realm", () => protectionSpace.realm);
args.putIfAbsent("port", () => protectionSpace.port);
await channel?.invokeMethod('removeHttpAuthCredentials', args);
}
@override
Future<void> clearAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('clearAllAuthCredentials', args);
}
@override
void dispose() {
// empty
}
}
extension InternalHttpAuthCredentialDatabase
on MacOSHttpAuthCredentialDatabase {
get handleMethod => _handleMethod;
}

View File

@ -0,0 +1,369 @@
import 'dart:async';
import 'dart:collection';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import '../find_interaction/find_interaction_controller.dart';
import '../in_app_webview/in_app_webview_controller.dart';
/// Object specifying creation parameters for creating a [MacOSInAppBrowser].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformInAppBrowserCreationParams] for
/// more information.
class MacOSInAppBrowserCreationParams
extends PlatformInAppBrowserCreationParams {
/// Creates a new [MacOSInAppBrowserCreationParams] instance.
MacOSInAppBrowserCreationParams(
{super.contextMenu,
super.pullToRefreshController,
this.findInteractionController,
super.initialUserScripts,
super.windowId});
/// Creates a [MacOSInAppBrowserCreationParams] instance based on [PlatformInAppBrowserCreationParams].
factory MacOSInAppBrowserCreationParams.fromPlatformInAppBrowserCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformInAppBrowserCreationParams params) {
return MacOSInAppBrowserCreationParams(
contextMenu: params.contextMenu,
pullToRefreshController: params.pullToRefreshController,
findInteractionController: params.findInteractionController
as MacOSFindInteractionController?,
initialUserScripts: params.initialUserScripts,
windowId: params.windowId);
}
@override
final MacOSFindInteractionController? findInteractionController;
}
///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser}
class MacOSInAppBrowser extends PlatformInAppBrowser with ChannelController {
@override
final String id = IdGenerator.generate();
/// Constructs a [MacOSInAppBrowser].
MacOSInAppBrowser(PlatformInAppBrowserCreationParams params)
: super.implementation(
params is MacOSInAppBrowserCreationParams
? params
: MacOSInAppBrowserCreationParams
.fromPlatformInAppBrowserCreationParams(params),
) {
_contextMenu = params.contextMenu;
}
static final MacOSInAppBrowser _staticValue =
MacOSInAppBrowser(MacOSInAppBrowserCreationParams());
/// Provide static access.
factory MacOSInAppBrowser.static() {
return _staticValue;
}
MacOSInAppBrowserCreationParams get _iosParams =>
params as MacOSInAppBrowserCreationParams;
static const MethodChannel _staticChannel =
const MethodChannel('com.pichillilorenzo/flutter_inappbrowser');
ContextMenu? _contextMenu;
@override
ContextMenu? get contextMenu => _contextMenu;
Map<int, InAppBrowserMenuItem> _menuItems = HashMap();
bool _isOpened = false;
MacOSInAppWebViewController? _webViewController;
@override
MacOSInAppWebViewController? get webViewController {
return _isOpened ? _webViewController : null;
}
_init() {
channel = MethodChannel('com.pichillilorenzo/flutter_inappbrowser_$id');
handler = _handleMethod;
initMethodCallHandler();
_webViewController = MacOSInAppWebViewController.fromInAppBrowser(
MacOSInAppWebViewControllerCreationParams(id: id),
channel!,
this,
this.initialUserScripts);
_iosParams.findInteractionController?.init(id);
}
_debugLog(String method, dynamic args) {
debugLog(
className: this.runtimeType.toString(),
id: id,
debugLoggingSettings: PlatformInAppBrowser.debugLoggingSettings,
method: method,
args: args);
}
Future<dynamic> _handleMethod(MethodCall call) async {
switch (call.method) {
case "onBrowserCreated":
_debugLog(call.method, call.arguments);
eventHandler?.onBrowserCreated();
break;
case "onMenuItemClicked":
_debugLog(call.method, call.arguments);
int id = call.arguments["id"].toInt();
if (this._menuItems[id] != null) {
if (this._menuItems[id]?.onClick != null) {
this._menuItems[id]?.onClick!();
}
}
break;
case "onExit":
_debugLog(call.method, call.arguments);
_isOpened = false;
final onExit = eventHandler?.onExit;
dispose();
onExit?.call();
break;
default:
return _webViewController?.handleMethod(call);
}
}
Map<String, dynamic> _prepareOpenRequest(
{@Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) {
assert(!_isOpened, 'The browser is already opened.');
_isOpened = true;
_init();
var initialSettings = settings?.toMap() ??
options?.toMap() ??
InAppBrowserClassSettings().toMap();
Map<String, dynamic> pullToRefreshSettings =
pullToRefreshController?.settings.toMap() ??
pullToRefreshController?.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
List<Map<String, dynamic>> menuItemList = [];
_menuItems.forEach((key, value) {
menuItemList.add(value.toMap());
});
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => id);
args.putIfAbsent('settings', () => initialSettings);
args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {});
args.putIfAbsent('windowId', () => windowId);
args.putIfAbsent('initialUserScripts',
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
args.putIfAbsent('menuItems', () => menuItemList);
return args;
}
@override
Future<void> openUrlRequest(
{required URLRequest urlRequest,
// ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async {
assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);
Map<String, dynamic> args =
_prepareOpenRequest(options: options, settings: settings);
args.putIfAbsent('urlRequest', () => urlRequest.toMap());
await _staticChannel.invokeMethod('open', args);
}
@override
Future<void> openFile(
{required String assetFilePath,
// ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async {
assert(assetFilePath.isNotEmpty);
Map<String, dynamic> args =
_prepareOpenRequest(options: options, settings: settings);
args.putIfAbsent('assetFilePath', () => assetFilePath);
await _staticChannel.invokeMethod('open', args);
}
@override
Future<void> openData(
{required String data,
String mimeType = "text/html",
String encoding = "utf8",
WebUri? baseUrl,
@Deprecated("Use historyUrl instead") Uri? androidHistoryUrl,
WebUri? historyUrl,
// ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async {
Map<String, dynamic> args =
_prepareOpenRequest(options: options, settings: settings);
args.putIfAbsent('data', () => data);
args.putIfAbsent('mimeType', () => mimeType);
args.putIfAbsent('encoding', () => encoding);
args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank");
args.putIfAbsent('historyUrl',
() => (historyUrl ?? androidHistoryUrl)?.toString() ?? "about:blank");
await _staticChannel.invokeMethod('open', args);
}
@override
Future<void> openWithSystemBrowser({required WebUri url}) async {
assert(url.toString().isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('url', () => url.toString());
return await _staticChannel.invokeMethod('openWithSystemBrowser', args);
}
@override
void addMenuItem(InAppBrowserMenuItem menuItem) {
_menuItems[menuItem.id] = menuItem;
}
@override
void addMenuItems(List<InAppBrowserMenuItem> menuItems) {
menuItems.forEach((menuItem) {
_menuItems[menuItem.id] = menuItem;
});
}
@override
bool removeMenuItem(InAppBrowserMenuItem menuItem) {
return _menuItems.remove(menuItem.id) != null;
}
@override
void removeMenuItems(List<InAppBrowserMenuItem> menuItems) {
for (final menuItem in menuItems) {
removeMenuItem(menuItem);
}
}
@override
void removeAllMenuItem() {
_menuItems.clear();
}
@override
bool hasMenuItem(InAppBrowserMenuItem menuItem) {
return _menuItems.containsKey(menuItem.id);
}
@override
Future<void> show() async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('show', args);
}
@override
Future<void> hide() async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('hide', args);
}
@override
Future<void> close() async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('close', args);
}
@override
Future<bool> isHidden() async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
return await channel?.invokeMethod<bool>('isHidden', args) ?? false;
}
@override
@Deprecated('Use setSettings instead')
Future<void> setOptions({required InAppBrowserClassOptions options}) async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('settings', () => options.toMap());
await channel?.invokeMethod('setSettings', args);
}
@override
@Deprecated('Use getSettings instead')
Future<InAppBrowserClassOptions?> getOptions() async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic>? options =
await channel?.invokeMethod('getSettings', args);
if (options != null) {
options = options.cast<String, dynamic>();
return InAppBrowserClassOptions.fromMap(options as Map<String, dynamic>);
}
return null;
}
@override
Future<void> setSettings(
{required InAppBrowserClassSettings settings}) async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('settings', () => settings.toMap());
await channel?.invokeMethod('setSettings', args);
}
@override
Future<InAppBrowserClassSettings?> getSettings() async {
assert(_isOpened, 'The browser is not opened.');
Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic>? settings =
await channel?.invokeMethod('getSettings', args);
if (settings != null) {
settings = settings.cast<String, dynamic>();
return InAppBrowserClassSettings.fromMap(
settings as Map<String, dynamic>);
}
return null;
}
@override
bool isOpened() {
return this._isOpened;
}
@override
@mustCallSuper
void dispose() {
disposeChannel();
_webViewController?.dispose();
_webViewController = null;
pullToRefreshController?.dispose();
findInteractionController?.dispose();
eventHandler = null;
}
}
extension InternalInAppBrowser on MacOSInAppBrowser {
void setContextMenu(ContextMenu? contextMenu) {
_contextMenu = contextMenu;
}
}

View File

@ -0,0 +1 @@
export 'in_app_browser.dart' hide InternalInAppBrowser;

View File

@ -0,0 +1,4 @@
import 'package:flutter/services.dart';
const IN_APP_WEBVIEW_STATIC_CHANNEL =
MethodChannel('com.pichillilorenzo/flutter_inappwebview_manager');

View File

@ -0,0 +1,434 @@
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import '../find_interaction/find_interaction_controller.dart';
import 'in_app_webview_controller.dart';
/// Object specifying creation parameters for creating a [MacOSCookieManager].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformHeadlessInAppWebViewCreationParams] for
/// more information.
@immutable
class MacOSHeadlessInAppWebViewCreationParams
extends PlatformHeadlessInAppWebViewCreationParams {
/// Creates a new [MacOSHeadlessInAppWebViewCreationParams] instance.
MacOSHeadlessInAppWebViewCreationParams(
{super.controllerFromPlatform,
super.initialSize,
super.windowId,
super.onWebViewCreated,
super.onLoadStart,
super.onLoadStop,
@Deprecated('Use onReceivedError instead') super.onLoadError,
super.onReceivedError,
@Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError,
super.onReceivedHttpError,
super.onProgressChanged,
super.onConsoleMessage,
super.shouldOverrideUrlLoading,
super.onLoadResource,
super.onScrollChanged,
@Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart,
super.onDownloadStartRequest,
@Deprecated('Use onLoadResourceWithCustomScheme instead')
super.onLoadResourceCustomScheme,
super.onLoadResourceWithCustomScheme,
super.onCreateWindow,
super.onCloseWindow,
super.onJsAlert,
super.onJsConfirm,
super.onJsPrompt,
super.onReceivedHttpAuthRequest,
super.onReceivedServerTrustAuthRequest,
super.onReceivedClientCertRequest,
@Deprecated('Use FindInteractionController.onFindResultReceived instead')
super.onFindResultReceived,
super.shouldInterceptAjaxRequest,
super.onAjaxReadyStateChange,
super.onAjaxProgress,
super.shouldInterceptFetchRequest,
super.onUpdateVisitedHistory,
@Deprecated("Use onPrintRequest instead") super.onPrint,
super.onPrintRequest,
super.onLongPressHitTestResult,
super.onEnterFullscreen,
super.onExitFullscreen,
super.onPageCommitVisible,
super.onTitleChanged,
super.onWindowFocus,
super.onWindowBlur,
super.onOverScrolled,
super.onZoomScaleChanged,
@Deprecated('Use onSafeBrowsingHit instead')
super.androidOnSafeBrowsingHit,
super.onSafeBrowsingHit,
@Deprecated('Use onPermissionRequest instead')
super.androidOnPermissionRequest,
super.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead')
super.androidOnGeolocationPermissionsShowPrompt,
super.onGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead')
super.androidOnGeolocationPermissionsHidePrompt,
super.onGeolocationPermissionsHidePrompt,
@Deprecated('Use shouldInterceptRequest instead')
super.androidShouldInterceptRequest,
super.shouldInterceptRequest,
@Deprecated('Use onRenderProcessGone instead')
super.androidOnRenderProcessGone,
super.onRenderProcessGone,
@Deprecated('Use onRenderProcessResponsive instead')
super.androidOnRenderProcessResponsive,
super.onRenderProcessResponsive,
@Deprecated('Use onRenderProcessUnresponsive instead')
super.androidOnRenderProcessUnresponsive,
super.onRenderProcessUnresponsive,
@Deprecated('Use onFormResubmission instead')
super.androidOnFormResubmission,
super.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon,
super.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead')
super.androidOnReceivedTouchIconUrl,
super.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload,
super.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead')
super.androidOnReceivedLoginRequest,
super.onReceivedLoginRequest,
super.onPermissionRequestCanceled,
super.onRequestFocus,
@Deprecated('Use onWebContentProcessDidTerminate instead')
super.iosOnWebContentProcessDidTerminate,
super.onWebContentProcessDidTerminate,
@Deprecated(
'Use onDidReceiveServerRedirectForProvisionalNavigation instead')
super.iosOnDidReceiveServerRedirectForProvisionalNavigation,
super.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead')
super.iosOnNavigationResponse,
super.onNavigationResponse,
@Deprecated('Use shouldAllowDeprecatedTLS instead')
super.iosShouldAllowDeprecatedTLS,
super.shouldAllowDeprecatedTLS,
super.onCameraCaptureStateChanged,
super.onMicrophoneCaptureStateChanged,
super.onContentSizeChanged,
super.initialUrlRequest,
super.initialFile,
super.initialData,
@Deprecated('Use initialSettings instead') super.initialOptions,
super.initialSettings,
super.contextMenu,
super.initialUserScripts,
super.pullToRefreshController,
this.findInteractionController});
/// Creates a [MacOSHeadlessInAppWebViewCreationParams] instance based on [PlatformHeadlessInAppWebViewCreationParams].
MacOSHeadlessInAppWebViewCreationParams.fromPlatformHeadlessInAppWebViewCreationParams(
PlatformHeadlessInAppWebViewCreationParams params)
: this(
controllerFromPlatform: params.controllerFromPlatform,
initialSize: params.initialSize,
windowId: params.windowId,
onWebViewCreated: params.onWebViewCreated,
onLoadStart: params.onLoadStart,
onLoadStop: params.onLoadStop,
onLoadError: params.onLoadError,
onReceivedError: params.onReceivedError,
onLoadHttpError: params.onLoadHttpError,
onReceivedHttpError: params.onReceivedHttpError,
onProgressChanged: params.onProgressChanged,
onConsoleMessage: params.onConsoleMessage,
shouldOverrideUrlLoading: params.shouldOverrideUrlLoading,
onLoadResource: params.onLoadResource,
onScrollChanged: params.onScrollChanged,
onDownloadStart: params.onDownloadStart,
onDownloadStartRequest: params.onDownloadStartRequest,
onLoadResourceCustomScheme: params.onLoadResourceCustomScheme,
onLoadResourceWithCustomScheme:
params.onLoadResourceWithCustomScheme,
onCreateWindow: params.onCreateWindow,
onCloseWindow: params.onCloseWindow,
onJsAlert: params.onJsAlert,
onJsConfirm: params.onJsConfirm,
onJsPrompt: params.onJsPrompt,
onReceivedHttpAuthRequest: params.onReceivedHttpAuthRequest,
onReceivedServerTrustAuthRequest:
params.onReceivedServerTrustAuthRequest,
onReceivedClientCertRequest: params.onReceivedClientCertRequest,
onFindResultReceived: params.onFindResultReceived,
shouldInterceptAjaxRequest: params.shouldInterceptAjaxRequest,
onAjaxReadyStateChange: params.onAjaxReadyStateChange,
onAjaxProgress: params.onAjaxProgress,
shouldInterceptFetchRequest: params.shouldInterceptFetchRequest,
onUpdateVisitedHistory: params.onUpdateVisitedHistory,
onPrint: params.onPrint,
onPrintRequest: params.onPrintRequest,
onLongPressHitTestResult: params.onLongPressHitTestResult,
onEnterFullscreen: params.onEnterFullscreen,
onExitFullscreen: params.onExitFullscreen,
onPageCommitVisible: params.onPageCommitVisible,
onTitleChanged: params.onTitleChanged,
onWindowFocus: params.onWindowFocus,
onWindowBlur: params.onWindowBlur,
onOverScrolled: params.onOverScrolled,
onZoomScaleChanged: params.onZoomScaleChanged,
androidOnSafeBrowsingHit: params.androidOnSafeBrowsingHit,
onSafeBrowsingHit: params.onSafeBrowsingHit,
androidOnPermissionRequest: params.androidOnPermissionRequest,
onPermissionRequest: params.onPermissionRequest,
androidOnGeolocationPermissionsShowPrompt:
params.androidOnGeolocationPermissionsShowPrompt,
onGeolocationPermissionsShowPrompt:
params.onGeolocationPermissionsShowPrompt,
androidOnGeolocationPermissionsHidePrompt:
params.androidOnGeolocationPermissionsHidePrompt,
onGeolocationPermissionsHidePrompt:
params.onGeolocationPermissionsHidePrompt,
androidShouldInterceptRequest: params.androidShouldInterceptRequest,
shouldInterceptRequest: params.shouldInterceptRequest,
androidOnRenderProcessGone: params.androidOnRenderProcessGone,
onRenderProcessGone: params.onRenderProcessGone,
androidOnRenderProcessResponsive:
params.androidOnRenderProcessResponsive,
onRenderProcessResponsive: params.onRenderProcessResponsive,
androidOnRenderProcessUnresponsive:
params.androidOnRenderProcessUnresponsive,
onRenderProcessUnresponsive: params.onRenderProcessUnresponsive,
androidOnFormResubmission: params.androidOnFormResubmission,
onFormResubmission: params.onFormResubmission,
androidOnScaleChanged: params.androidOnScaleChanged,
androidOnReceivedIcon: params.androidOnReceivedIcon,
onReceivedIcon: params.onReceivedIcon,
androidOnReceivedTouchIconUrl: params.androidOnReceivedTouchIconUrl,
onReceivedTouchIconUrl: params.onReceivedTouchIconUrl,
androidOnJsBeforeUnload: params.androidOnJsBeforeUnload,
onJsBeforeUnload: params.onJsBeforeUnload,
androidOnReceivedLoginRequest: params.androidOnReceivedLoginRequest,
onReceivedLoginRequest: params.onReceivedLoginRequest,
onPermissionRequestCanceled: params.onPermissionRequestCanceled,
onRequestFocus: params.onRequestFocus,
iosOnWebContentProcessDidTerminate:
params.iosOnWebContentProcessDidTerminate,
onWebContentProcessDidTerminate:
params.onWebContentProcessDidTerminate,
iosOnDidReceiveServerRedirectForProvisionalNavigation:
params.iosOnDidReceiveServerRedirectForProvisionalNavigation,
onDidReceiveServerRedirectForProvisionalNavigation:
params.onDidReceiveServerRedirectForProvisionalNavigation,
iosOnNavigationResponse: params.iosOnNavigationResponse,
onNavigationResponse: params.onNavigationResponse,
iosShouldAllowDeprecatedTLS: params.iosShouldAllowDeprecatedTLS,
shouldAllowDeprecatedTLS: params.shouldAllowDeprecatedTLS,
onCameraCaptureStateChanged: params.onCameraCaptureStateChanged,
onMicrophoneCaptureStateChanged:
params.onMicrophoneCaptureStateChanged,
onContentSizeChanged: params.onContentSizeChanged,
initialUrlRequest: params.initialUrlRequest,
initialFile: params.initialFile,
initialData: params.initialData,
initialOptions: params.initialOptions,
initialSettings: params.initialSettings,
contextMenu: params.contextMenu,
initialUserScripts: params.initialUserScripts,
pullToRefreshController: params.pullToRefreshController,
findInteractionController: params.findInteractionController
as MacOSFindInteractionController?);
@override
final MacOSFindInteractionController? findInteractionController;
}
///{@macro flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebView}
class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView
with ChannelController {
@override
late final String id;
bool _started = false;
bool _running = false;
static const MethodChannel _sharedChannel =
const MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview');
MacOSInAppWebViewController? _webViewController;
/// Constructs a [MacOSHeadlessInAppWebView].
MacOSHeadlessInAppWebView(PlatformHeadlessInAppWebViewCreationParams params)
: super.implementation(
params is MacOSHeadlessInAppWebViewCreationParams
? params
: MacOSHeadlessInAppWebViewCreationParams
.fromPlatformHeadlessInAppWebViewCreationParams(params),
) {
id = IdGenerator.generate();
}
@override
MacOSInAppWebViewController? get webViewController => _webViewController;
dynamic _controllerFromPlatform;
MacOSHeadlessInAppWebViewCreationParams get _iosParams =>
params as MacOSHeadlessInAppWebViewCreationParams;
_init() {
_webViewController = MacOSInAppWebViewController(
MacOSInAppWebViewControllerCreationParams(
id: id, webviewParams: params),
);
_controllerFromPlatform =
params.controllerFromPlatform?.call(_webViewController!) ??
_webViewController!;
_iosParams.findInteractionController?.init(id);
channel =
MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview_$id');
handler = _handleMethod;
initMethodCallHandler();
}
Future<dynamic> _handleMethod(MethodCall call) async {
switch (call.method) {
case "onWebViewCreated":
if (params.onWebViewCreated != null && _webViewController != null) {
params.onWebViewCreated!(_controllerFromPlatform);
}
break;
default:
throw UnimplementedError("Unimplemented ${call.method} method");
}
return null;
}
Future<void> run() async {
if (_started) {
return;
}
_started = true;
_init();
final initialSettings = params.initialSettings ?? InAppWebViewSettings();
_inferInitialSettings(initialSettings);
Map<String, dynamic> settingsMap =
(params.initialSettings != null ? initialSettings.toMap() : null) ??
params.initialOptions?.toMap() ??
initialSettings.toMap();
Map<String, dynamic> pullToRefreshSettings =
_iosParams.pullToRefreshController?.params.settings.toMap() ??
_iosParams.pullToRefreshController?.params.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => id);
args.putIfAbsent(
'params',
() => <String, dynamic>{
'initialUrlRequest': params.initialUrlRequest?.toMap(),
'initialFile': params.initialFile,
'initialData': params.initialData?.toMap(),
'initialSettings': settingsMap,
'contextMenu': params.contextMenu?.toMap() ?? {},
'windowId': params.windowId,
'initialUserScripts':
params.initialUserScripts?.map((e) => e.toMap()).toList() ??
[],
'pullToRefreshSettings': pullToRefreshSettings,
'initialSize': params.initialSize.toMap()
});
await _sharedChannel.invokeMethod('run', args);
_running = true;
}
void _inferInitialSettings(InAppWebViewSettings settings) {
if (params.shouldOverrideUrlLoading != null &&
settings.useShouldOverrideUrlLoading == null) {
settings.useShouldOverrideUrlLoading = true;
}
if (params.onLoadResource != null && settings.useOnLoadResource == null) {
settings.useOnLoadResource = true;
}
if (params.onDownloadStartRequest != null &&
settings.useOnDownloadStart == null) {
settings.useOnDownloadStart = true;
}
if (params.shouldInterceptAjaxRequest != null &&
settings.useShouldInterceptAjaxRequest == null) {
settings.useShouldInterceptAjaxRequest = true;
}
if (params.shouldInterceptFetchRequest != null &&
settings.useShouldInterceptFetchRequest == null) {
settings.useShouldInterceptFetchRequest = true;
}
if (params.shouldInterceptRequest != null &&
settings.useShouldInterceptRequest == null) {
settings.useShouldInterceptRequest = true;
}
if (params.onRenderProcessGone != null &&
settings.useOnRenderProcessGone == null) {
settings.useOnRenderProcessGone = true;
}
if (params.onNavigationResponse != null &&
settings.useOnNavigationResponse == null) {
settings.useOnNavigationResponse = true;
}
}
@override
bool isRunning() {
return _running;
}
@override
Future<void> setSize(Size size) async {
if (!_running) {
return;
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('size', () => size.toMap());
await channel?.invokeMethod('setSize', args);
}
@override
Future<Size?> getSize() async {
if (!_running) {
return null;
}
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic> sizeMap =
(await channel?.invokeMethod('getSize', args))?.cast<String, dynamic>();
return MapSize.fromMap(sizeMap);
}
@override
Future<void> dispose() async {
if (!_running) {
return;
}
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('dispose', args);
disposeChannel();
_started = false;
_running = false;
_webViewController?.dispose();
_webViewController = null;
_controllerFromPlatform = null;
_iosParams.pullToRefreshController?.dispose();
_iosParams.findInteractionController?.dispose();
}
}
extension InternalHeadlessInAppWebView on MacOSHeadlessInAppWebView {
Future<void> internalDispose() async {
_started = false;
_running = false;
}
}

View File

@ -0,0 +1,418 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import 'headless_in_app_webview.dart';
import '../find_interaction/find_interaction_controller.dart';
import 'in_app_webview_controller.dart';
/// Object specifying creation parameters for creating a [PlatformInAppWebViewWidget].
///
/// Platform specific implementations can add additional fields by extending
/// this class.
class MacOSInAppWebViewWidgetCreationParams
extends PlatformInAppWebViewWidgetCreationParams {
MacOSInAppWebViewWidgetCreationParams(
{super.controllerFromPlatform,
super.key,
super.layoutDirection,
super.gestureRecognizers,
super.headlessWebView,
super.keepAlive,
super.preventGestureDelay,
super.windowId,
super.onWebViewCreated,
super.onLoadStart,
super.onLoadStop,
@Deprecated('Use onReceivedError instead') super.onLoadError,
super.onReceivedError,
@Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError,
super.onReceivedHttpError,
super.onProgressChanged,
super.onConsoleMessage,
super.shouldOverrideUrlLoading,
super.onLoadResource,
super.onScrollChanged,
@Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart,
super.onDownloadStartRequest,
@Deprecated('Use onLoadResourceWithCustomScheme instead')
super.onLoadResourceCustomScheme,
super.onLoadResourceWithCustomScheme,
super.onCreateWindow,
super.onCloseWindow,
super.onJsAlert,
super.onJsConfirm,
super.onJsPrompt,
super.onReceivedHttpAuthRequest,
super.onReceivedServerTrustAuthRequest,
super.onReceivedClientCertRequest,
@Deprecated('Use FindInteractionController.onFindResultReceived instead')
super.onFindResultReceived,
super.shouldInterceptAjaxRequest,
super.onAjaxReadyStateChange,
super.onAjaxProgress,
super.shouldInterceptFetchRequest,
super.onUpdateVisitedHistory,
@Deprecated("Use onPrintRequest instead") super.onPrint,
super.onPrintRequest,
super.onLongPressHitTestResult,
super.onEnterFullscreen,
super.onExitFullscreen,
super.onPageCommitVisible,
super.onTitleChanged,
super.onWindowFocus,
super.onWindowBlur,
super.onOverScrolled,
super.onZoomScaleChanged,
@Deprecated('Use onSafeBrowsingHit instead')
super.androidOnSafeBrowsingHit,
super.onSafeBrowsingHit,
@Deprecated('Use onPermissionRequest instead')
super.androidOnPermissionRequest,
super.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead')
super.androidOnGeolocationPermissionsShowPrompt,
super.onGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead')
super.androidOnGeolocationPermissionsHidePrompt,
super.onGeolocationPermissionsHidePrompt,
@Deprecated('Use shouldInterceptRequest instead')
super.androidShouldInterceptRequest,
super.shouldInterceptRequest,
@Deprecated('Use onRenderProcessGone instead')
super.androidOnRenderProcessGone,
super.onRenderProcessGone,
@Deprecated('Use onRenderProcessResponsive instead')
super.androidOnRenderProcessResponsive,
super.onRenderProcessResponsive,
@Deprecated('Use onRenderProcessUnresponsive instead')
super.androidOnRenderProcessUnresponsive,
super.onRenderProcessUnresponsive,
@Deprecated('Use onFormResubmission instead')
super.androidOnFormResubmission,
super.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon,
super.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead')
super.androidOnReceivedTouchIconUrl,
super.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload,
super.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead')
super.androidOnReceivedLoginRequest,
super.onReceivedLoginRequest,
super.onPermissionRequestCanceled,
super.onRequestFocus,
@Deprecated('Use onWebContentProcessDidTerminate instead')
super.iosOnWebContentProcessDidTerminate,
super.onWebContentProcessDidTerminate,
@Deprecated(
'Use onDidReceiveServerRedirectForProvisionalNavigation instead')
super.iosOnDidReceiveServerRedirectForProvisionalNavigation,
super.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead')
super.iosOnNavigationResponse,
super.onNavigationResponse,
@Deprecated('Use shouldAllowDeprecatedTLS instead')
super.iosShouldAllowDeprecatedTLS,
super.shouldAllowDeprecatedTLS,
super.onCameraCaptureStateChanged,
super.onMicrophoneCaptureStateChanged,
super.onContentSizeChanged,
super.initialUrlRequest,
super.initialFile,
super.initialData,
@Deprecated('Use initialSettings instead') super.initialOptions,
super.initialSettings,
super.contextMenu,
super.initialUserScripts,
super.pullToRefreshController,
this.findInteractionController});
/// Constructs a [MacOSInAppWebViewWidgetCreationParams] using a
/// [PlatformInAppWebViewWidgetCreationParams].
MacOSInAppWebViewWidgetCreationParams.fromPlatformInAppWebViewWidgetCreationParams(
PlatformInAppWebViewWidgetCreationParams params)
: this(
controllerFromPlatform: params.controllerFromPlatform,
key: params.key,
layoutDirection: params.layoutDirection,
gestureRecognizers: params.gestureRecognizers,
headlessWebView: params.headlessWebView,
keepAlive: params.keepAlive,
preventGestureDelay: params.preventGestureDelay,
windowId: params.windowId,
onWebViewCreated: params.onWebViewCreated,
onLoadStart: params.onLoadStart,
onLoadStop: params.onLoadStop,
onLoadError: params.onLoadError,
onReceivedError: params.onReceivedError,
onLoadHttpError: params.onLoadHttpError,
onReceivedHttpError: params.onReceivedHttpError,
onProgressChanged: params.onProgressChanged,
onConsoleMessage: params.onConsoleMessage,
shouldOverrideUrlLoading: params.shouldOverrideUrlLoading,
onLoadResource: params.onLoadResource,
onScrollChanged: params.onScrollChanged,
onDownloadStart: params.onDownloadStart,
onDownloadStartRequest: params.onDownloadStartRequest,
onLoadResourceCustomScheme: params.onLoadResourceCustomScheme,
onLoadResourceWithCustomScheme:
params.onLoadResourceWithCustomScheme,
onCreateWindow: params.onCreateWindow,
onCloseWindow: params.onCloseWindow,
onJsAlert: params.onJsAlert,
onJsConfirm: params.onJsConfirm,
onJsPrompt: params.onJsPrompt,
onReceivedHttpAuthRequest: params.onReceivedHttpAuthRequest,
onReceivedServerTrustAuthRequest:
params.onReceivedServerTrustAuthRequest,
onReceivedClientCertRequest: params.onReceivedClientCertRequest,
onFindResultReceived: params.onFindResultReceived,
shouldInterceptAjaxRequest: params.shouldInterceptAjaxRequest,
onAjaxReadyStateChange: params.onAjaxReadyStateChange,
onAjaxProgress: params.onAjaxProgress,
shouldInterceptFetchRequest: params.shouldInterceptFetchRequest,
onUpdateVisitedHistory: params.onUpdateVisitedHistory,
onPrint: params.onPrint,
onPrintRequest: params.onPrintRequest,
onLongPressHitTestResult: params.onLongPressHitTestResult,
onEnterFullscreen: params.onEnterFullscreen,
onExitFullscreen: params.onExitFullscreen,
onPageCommitVisible: params.onPageCommitVisible,
onTitleChanged: params.onTitleChanged,
onWindowFocus: params.onWindowFocus,
onWindowBlur: params.onWindowBlur,
onOverScrolled: params.onOverScrolled,
onZoomScaleChanged: params.onZoomScaleChanged,
androidOnSafeBrowsingHit: params.androidOnSafeBrowsingHit,
onSafeBrowsingHit: params.onSafeBrowsingHit,
androidOnPermissionRequest: params.androidOnPermissionRequest,
onPermissionRequest: params.onPermissionRequest,
androidOnGeolocationPermissionsShowPrompt:
params.androidOnGeolocationPermissionsShowPrompt,
onGeolocationPermissionsShowPrompt:
params.onGeolocationPermissionsShowPrompt,
androidOnGeolocationPermissionsHidePrompt:
params.androidOnGeolocationPermissionsHidePrompt,
onGeolocationPermissionsHidePrompt:
params.onGeolocationPermissionsHidePrompt,
androidShouldInterceptRequest: params.androidShouldInterceptRequest,
shouldInterceptRequest: params.shouldInterceptRequest,
androidOnRenderProcessGone: params.androidOnRenderProcessGone,
onRenderProcessGone: params.onRenderProcessGone,
androidOnRenderProcessResponsive:
params.androidOnRenderProcessResponsive,
onRenderProcessResponsive: params.onRenderProcessResponsive,
androidOnRenderProcessUnresponsive:
params.androidOnRenderProcessUnresponsive,
onRenderProcessUnresponsive: params.onRenderProcessUnresponsive,
androidOnFormResubmission: params.androidOnFormResubmission,
onFormResubmission: params.onFormResubmission,
androidOnScaleChanged: params.androidOnScaleChanged,
androidOnReceivedIcon: params.androidOnReceivedIcon,
onReceivedIcon: params.onReceivedIcon,
androidOnReceivedTouchIconUrl: params.androidOnReceivedTouchIconUrl,
onReceivedTouchIconUrl: params.onReceivedTouchIconUrl,
androidOnJsBeforeUnload: params.androidOnJsBeforeUnload,
onJsBeforeUnload: params.onJsBeforeUnload,
androidOnReceivedLoginRequest: params.androidOnReceivedLoginRequest,
onReceivedLoginRequest: params.onReceivedLoginRequest,
onPermissionRequestCanceled: params.onPermissionRequestCanceled,
onRequestFocus: params.onRequestFocus,
iosOnWebContentProcessDidTerminate:
params.iosOnWebContentProcessDidTerminate,
onWebContentProcessDidTerminate:
params.onWebContentProcessDidTerminate,
iosOnDidReceiveServerRedirectForProvisionalNavigation:
params.iosOnDidReceiveServerRedirectForProvisionalNavigation,
onDidReceiveServerRedirectForProvisionalNavigation:
params.onDidReceiveServerRedirectForProvisionalNavigation,
iosOnNavigationResponse: params.iosOnNavigationResponse,
onNavigationResponse: params.onNavigationResponse,
iosShouldAllowDeprecatedTLS: params.iosShouldAllowDeprecatedTLS,
shouldAllowDeprecatedTLS: params.shouldAllowDeprecatedTLS,
onCameraCaptureStateChanged: params.onCameraCaptureStateChanged,
onMicrophoneCaptureStateChanged:
params.onMicrophoneCaptureStateChanged,
onContentSizeChanged: params.onContentSizeChanged,
initialUrlRequest: params.initialUrlRequest,
initialFile: params.initialFile,
initialData: params.initialData,
initialOptions: params.initialOptions,
initialSettings: params.initialSettings,
contextMenu: params.contextMenu,
initialUserScripts: params.initialUserScripts,
pullToRefreshController: params.pullToRefreshController,
findInteractionController: params.findInteractionController
as MacOSFindInteractionController?);
@override
final MacOSFindInteractionController? findInteractionController;
}
///{@template flutter_inappwebview.InAppWebView}
///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 {
/// Constructs a [MacOSInAppWebViewWidget].
MacOSInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params)
: super.implementation(
params is MacOSInAppWebViewWidgetCreationParams
? params
: MacOSInAppWebViewWidgetCreationParams
.fromPlatformInAppWebViewWidgetCreationParams(params),
);
MacOSInAppWebViewWidgetCreationParams get _iosParams =>
params as MacOSInAppWebViewWidgetCreationParams;
MacOSInAppWebViewController? _controller;
MacOSHeadlessInAppWebView? get _iosHeadlessInAppWebView =>
_iosParams.headlessWebView as MacOSHeadlessInAppWebView?;
@override
Widget build(BuildContext context) {
final initialSettings =
_iosParams.initialSettings ?? InAppWebViewSettings();
_inferInitialSettings(initialSettings);
Map<String, dynamic> settingsMap = (_iosParams.initialSettings != null
? initialSettings.toMap()
: null) ??
// ignore: deprecated_member_use_from_same_package
_iosParams.initialOptions?.toMap() ??
initialSettings.toMap();
Map<String, dynamic> pullToRefreshSettings =
_iosParams.pullToRefreshController?.params.settings.toMap() ??
// ignore: deprecated_member_use_from_same_package
_iosParams.pullToRefreshController?.params.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
if ((_iosParams.headlessWebView?.isRunning() ?? false) &&
_iosParams.keepAlive != null) {
final headlessId = _iosParams.headlessWebView?.id;
if (headlessId != null) {
// force keep alive id to match headless webview id
_iosParams.keepAlive?.id = headlessId;
}
}
return UiKitView(
viewType: 'com.pichillilorenzo/flutter_inappwebview',
onPlatformViewCreated: _onPlatformViewCreated,
gestureRecognizers: _iosParams.gestureRecognizers,
creationParams: <String, dynamic>{
'initialUrlRequest': _iosParams.initialUrlRequest?.toMap(),
'initialFile': _iosParams.initialFile,
'initialData': _iosParams.initialData?.toMap(),
'initialSettings': settingsMap,
'contextMenu': _iosParams.contextMenu?.toMap() ?? {},
'windowId': _iosParams.windowId,
'headlessWebViewId': _iosParams.headlessWebView?.isRunning() ?? false
? _iosParams.headlessWebView?.id
: null,
'initialUserScripts':
_iosParams.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
'pullToRefreshSettings': pullToRefreshSettings,
'keepAliveId': _iosParams.keepAlive?.id,
'preventGestureDelay': _iosParams.preventGestureDelay
},
creationParamsCodec: const StandardMessageCodec(),
);
}
void _onPlatformViewCreated(int id) {
dynamic viewId = id;
if (!kIsWeb) {
if (_iosParams.headlessWebView?.isRunning() ?? false) {
viewId = _iosParams.headlessWebView?.id;
}
viewId = _iosParams.keepAlive?.id ?? viewId ?? id;
}
_iosHeadlessInAppWebView?.internalDispose();
_controller = MacOSInAppWebViewController(
PlatformInAppWebViewControllerCreationParams(
id: viewId, webviewParams: params));
_iosParams.findInteractionController?.init(viewId);
debugLog(
className: runtimeType.toString(),
id: viewId?.toString(),
debugLoggingSettings:
PlatformInAppWebViewController.debugLoggingSettings,
method: "onWebViewCreated",
args: []);
if (_iosParams.onWebViewCreated != null) {
_iosParams.onWebViewCreated!(
params.controllerFromPlatform?.call(_controller!) ?? _controller!);
}
}
void _inferInitialSettings(InAppWebViewSettings settings) {
if (_iosParams.shouldOverrideUrlLoading != null &&
settings.useShouldOverrideUrlLoading == null) {
settings.useShouldOverrideUrlLoading = true;
}
if (_iosParams.onLoadResource != null &&
settings.useOnLoadResource == null) {
settings.useOnLoadResource = true;
}
if (_iosParams.onDownloadStartRequest != null &&
settings.useOnDownloadStart == null) {
settings.useOnDownloadStart = true;
}
if (_iosParams.shouldInterceptAjaxRequest != null &&
settings.useShouldInterceptAjaxRequest == null) {
settings.useShouldInterceptAjaxRequest = true;
}
if (_iosParams.shouldInterceptFetchRequest != null &&
settings.useShouldInterceptFetchRequest == null) {
settings.useShouldInterceptFetchRequest = true;
}
if (_iosParams.shouldInterceptRequest != null &&
settings.useShouldInterceptRequest == null) {
settings.useShouldInterceptRequest = true;
}
if (_iosParams.onRenderProcessGone != null &&
settings.useOnRenderProcessGone == null) {
settings.useOnRenderProcessGone = true;
}
if (_iosParams.onNavigationResponse != null &&
settings.useOnNavigationResponse == null) {
settings.useOnNavigationResponse = true;
}
}
@override
void dispose() {
dynamic viewId = _controller?.getViewId();
debugLog(
className: runtimeType.toString(),
id: viewId?.toString(),
debugLoggingSettings:
PlatformInAppWebViewController.debugLoggingSettings,
method: "dispose",
args: []);
final isKeepAlive = _iosParams.keepAlive != null;
_controller?.dispose(isKeepAlive: isKeepAlive);
_controller = null;
_iosParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive);
_iosParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive);
}
@override
T controllerFromPlatform<T>(PlatformInAppWebViewController controller) {
// unused
throw UnimplementedError();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
export 'in_app_webview_controller.dart' hide InternalInAppWebViewController;
export 'in_app_webview.dart';
export 'headless_in_app_webview.dart' hide InternalHeadlessInAppWebView;

View File

@ -0,0 +1,240 @@
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import 'cookie_manager.dart';
import 'http_auth_credentials_database.dart';
import 'find_interaction/main.dart';
import 'in_app_browser/in_app_browser.dart';
import 'in_app_webview/main.dart';
import 'print_job/main.dart';
import 'web_message/main.dart';
import 'web_storage/main.dart';
import 'web_authentication_session/main.dart';
/// Implementation of [InAppWebViewPlatform] using the WebKit API.
class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
/// Registers this class as the default instance of [InAppWebViewPlatform].
static void registerWith() {
InAppWebViewPlatform.instance = MacOSInAppWebViewPlatform();
}
/// Creates a new [MacOSCookieManager].
///
/// This function should only be called by the app-facing package.
/// Look at using [CookieManager] in `flutter_inappwebview` instead.
@override
MacOSCookieManager createPlatformCookieManager(
PlatformCookieManagerCreationParams params,
) {
return MacOSCookieManager(params);
}
/// Creates a new [MacOSInAppWebViewController].
///
/// This function should only be called by the app-facing package.
/// Look at using [InAppWebViewController] in `flutter_inappwebview` instead.
@override
MacOSInAppWebViewController createPlatformInAppWebViewController(
PlatformInAppWebViewControllerCreationParams params,
) {
return MacOSInAppWebViewController(params);
}
/// Creates a new empty [MacOSInAppWebViewController] to access static methods.
///
/// This function should only be called by the app-facing package.
/// Look at using [InAppWebViewController] in `flutter_inappwebview` instead.
@override
MacOSInAppWebViewController createPlatformInAppWebViewControllerStatic() {
return MacOSInAppWebViewController.static();
}
/// Creates a new [MacOSInAppWebViewWidget].
///
/// This function should only be called by the app-facing package.
/// Look at using [InAppWebView] in `flutter_inappwebview` instead.
@override
MacOSInAppWebViewWidget createPlatformInAppWebViewWidget(
PlatformInAppWebViewWidgetCreationParams params,
) {
return MacOSInAppWebViewWidget(params);
}
/// Creates a new [MacOSFindInteractionController].
///
/// This function should only be called by the app-facing package.
/// Look at using [FindInteractionController] in `flutter_inappwebview` instead.
@override
MacOSFindInteractionController createPlatformFindInteractionController(
PlatformFindInteractionControllerCreationParams params,
) {
return MacOSFindInteractionController(params);
}
/// Creates a new [MacOSPrintJobController].
///
/// This function should only be called by the app-facing package.
/// Look at using [PrintJobController] in `flutter_inappwebview` instead.
@override
MacOSPrintJobController createPlatformPrintJobController(
PlatformPrintJobControllerCreationParams params,
) {
return MacOSPrintJobController(params);
}
/// Creates a new [MacOSWebMessageChannel].
///
/// This function should only be called by the app-facing package.
/// Look at using [WebMessageChannel] in `flutter_inappwebview` instead.
@override
MacOSWebMessageChannel createPlatformWebMessageChannel(
PlatformWebMessageChannelCreationParams params,
) {
return MacOSWebMessageChannel(params);
}
/// Creates a new empty [MacOSWebMessageChannel] to access static methods.
///
/// This function should only be called by the app-facing package.
/// Look at using [WebMessageChannel] in `flutter_inappwebview` instead.
@override
MacOSWebMessageChannel createPlatformWebMessageChannelStatic() {
return MacOSWebMessageChannel.static();
}
/// Creates a new [MacOSWebMessageListener].
///
/// This function should only be called by the app-facing package.
/// Look at using [WebMessageListener] in `flutter_inappwebview` instead.
@override
MacOSWebMessageListener createPlatformWebMessageListener(
PlatformWebMessageListenerCreationParams params,
) {
return MacOSWebMessageListener(params);
}
/// Creates a new [MacOSJavaScriptReplyProxy].
///
/// This function should only be called by the app-facing package.
/// Look at using [JavaScriptReplyProxy] in `flutter_inappwebview` instead.
@override
MacOSJavaScriptReplyProxy createPlatformJavaScriptReplyProxy(
PlatformJavaScriptReplyProxyCreationParams params,
) {
return MacOSJavaScriptReplyProxy(params);
}
/// Creates a new [MacOSWebMessagePort].
///
/// This function should only be called by the app-facing package.
/// Look at using [WebMessagePort] in `flutter_inappwebview` instead.
@override
MacOSWebMessagePort createPlatformWebMessagePort(
PlatformWebMessagePortCreationParams params,
) {
return MacOSWebMessagePort(params);
}
/// Creates a new [MacOSWebStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [MacOSWebStorage] in `flutter_inappwebview` instead.
@override
MacOSWebStorage createPlatformWebStorage(
PlatformWebStorageCreationParams params,
) {
return MacOSWebStorage(params);
}
/// Creates a new [MacOSLocalStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [MacOSLocalStorage] in `flutter_inappwebview` instead.
@override
MacOSLocalStorage createPlatformLocalStorage(
PlatformLocalStorageCreationParams params,
) {
return MacOSLocalStorage(params);
}
/// Creates a new [MacOSSessionStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead.
@override
MacOSSessionStorage createPlatformSessionStorage(
PlatformSessionStorageCreationParams params,
) {
return MacOSSessionStorage(params);
}
/// Creates a new [MacOSHeadlessInAppWebView].
///
/// This function should only be called by the app-facing package.
/// Look at using [HeadlessInAppWebView] in `flutter_inappwebview` instead.
@override
MacOSHeadlessInAppWebView createPlatformHeadlessInAppWebView(
PlatformHeadlessInAppWebViewCreationParams params,
) {
return MacOSHeadlessInAppWebView(params);
}
/// Creates a new [MacOSHttpAuthCredentialDatabase].
///
/// This function should only be called by the app-facing package.
/// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead.
@override
MacOSHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabase(
PlatformHttpAuthCredentialDatabaseCreationParams params,
) {
return MacOSHttpAuthCredentialDatabase(params);
}
/// Creates a new [MacOSInAppBrowser].
///
/// This function should only be called by the app-facing package.
/// Look at using [InAppBrowser] in `flutter_inappwebview` instead.
@override
MacOSInAppBrowser createPlatformInAppBrowser(
PlatformInAppBrowserCreationParams params,
) {
return MacOSInAppBrowser(params);
}
/// Creates a new empty [MacOSInAppBrowser] to access static methods.
///
/// This function should only be called by the app-facing package.
/// Look at using [InAppBrowser] in `flutter_inappwebview` instead.
@override
MacOSInAppBrowser createPlatformInAppBrowserStatic() {
return MacOSInAppBrowser.static();
}
/// Creates a new empty [MacOSWebStorageManager] to access static methods.
///
/// This function should only be called by the app-facing package.
/// Look at using [WebStorageManager] in `flutter_inappwebview` instead.
@override
MacOSWebStorageManager createPlatformWebStorageManager(
PlatformWebStorageManagerCreationParams params) {
return MacOSWebStorageManager(params);
}
/// Creates a new [MacOSWebAuthenticationSession].
///
/// This function should only be called by the app-facing package.
/// Look at using [WebAuthenticationSession] in `flutter_inappwebview` instead.
@override
MacOSWebAuthenticationSession createPlatformWebAuthenticationSession(
PlatformWebAuthenticationSessionCreationParams params) {
return MacOSWebAuthenticationSession(params);
}
/// Creates a new empty [MacOSWebAuthenticationSession] to access static methods.
///
/// This function should only be called by the app-facing package.
/// Look at using [WebAuthenticationSession] in `flutter_inappwebview` instead.
@override
MacOSWebAuthenticationSession createPlatformWebAuthenticationSessionStatic() {
return MacOSWebAuthenticationSession.static();
}
}

View File

@ -0,0 +1,11 @@
export 'inappwebview_platform.dart';
export 'in_app_webview/main.dart';
export 'in_app_browser/main.dart';
export 'web_storage/main.dart';
export 'cookie_manager.dart' hide InternalCookieManager;
export 'http_auth_credentials_database.dart'
hide InternalHttpAuthCredentialDatabase;
export 'web_message/main.dart';
export 'print_job/main.dart';
export 'find_interaction/main.dart';
export 'web_authentication_session/main.dart';

View File

@ -0,0 +1,64 @@
import 'package:flutter/services.dart';
///Platform native utilities
class PlatformUtil {
static PlatformUtil? _instance;
static const MethodChannel _channel =
MethodChannel('com.pichillilorenzo/flutter_inappwebview_platformutil');
PlatformUtil._();
///Get [PlatformUtil] instance.
static PlatformUtil instance() {
return (_instance != null) ? _instance! : _init();
}
static PlatformUtil _init() {
_channel.setMethodCallHandler((call) async {
try {
return await _handleMethod(call);
} on Error catch (e) {
print(e);
print(e.stackTrace);
}
});
_instance = PlatformUtil._();
return _instance!;
}
static Future<dynamic> _handleMethod(MethodCall call) async {}
String? _cachedSystemVersion;
///Get current platform system version.
Future<String> getSystemVersion() async {
if (_cachedSystemVersion != null) {
return _cachedSystemVersion!;
}
Map<String, dynamic> args = <String, dynamic>{};
_cachedSystemVersion =
await _channel.invokeMethod('getSystemVersion', args);
return _cachedSystemVersion!;
}
///Format date.
Future<String> formatDate(
{required DateTime date,
required String format,
String locale = "en_US",
String timezone = "UTC"}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('date', () => date.millisecondsSinceEpoch);
args.putIfAbsent('format', () => format);
args.putIfAbsent('locale', () => locale);
args.putIfAbsent('timezone', () => timezone);
return await _channel.invokeMethod('formatDate', args);
}
///Get cookie expiration date used by Web platform.
Future<String> getWebCookieExpirationDate({required DateTime date}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('date', () => date.millisecondsSinceEpoch);
return await _channel.invokeMethod('getWebCookieExpirationDate', args);
}
}

View File

@ -0,0 +1 @@
export 'print_job_controller.dart';

View File

@ -0,0 +1,72 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
/// Object specifying creation parameters for creating a [MacOSPrintJobController].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformPrintJobControllerCreationParams] for
/// more information.
@immutable
class MacOSPrintJobControllerCreationParams
extends PlatformPrintJobControllerCreationParams {
/// Creates a new [MacOSPrintJobControllerCreationParams] instance.
const MacOSPrintJobControllerCreationParams(
{required super.id, super.onComplete});
/// Creates a [MacOSPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams].
factory MacOSPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformPrintJobControllerCreationParams params) {
return MacOSPrintJobControllerCreationParams(
id: params.id, onComplete: params.onComplete);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController}
class MacOSPrintJobController extends PlatformPrintJobController
with ChannelController {
/// Constructs a [MacOSPrintJobController].
MacOSPrintJobController(PlatformPrintJobControllerCreationParams params)
: super.implementation(
params is MacOSPrintJobControllerCreationParams
? params
: MacOSPrintJobControllerCreationParams
.fromPlatformPrintJobControllerCreationParams(params),
) {
channel = MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_printjobcontroller_${params.id}');
handler = _handleMethod;
initMethodCallHandler();
}
Future<dynamic> _handleMethod(MethodCall call) async {
switch (call.method) {
case "onComplete":
bool completed = call.arguments["completed"];
String? error = call.arguments["error"];
if (params.onComplete != null) {
params.onComplete!(completed, error);
}
break;
default:
throw UnimplementedError("Unimplemented ${call.method} method");
}
}
@override
Future<PrintJobInfo?> getInfo() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? infoMap =
(await channel?.invokeMethod('getInfo', args))?.cast<String, dynamic>();
return PrintJobInfo.fromMap(infoMap);
}
@override
Future<void> dispose() async {
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('dispose', args);
disposeChannel();
}
}

View File

@ -0,0 +1 @@
export 'web_authenticate_session.dart';

View File

@ -0,0 +1,165 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
/// Object specifying creation parameters for creating a [MacOSWebAuthenticationSession].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformWebAuthenticationSessionCreationParams] for
/// more information.
class MacOSWebAuthenticationSessionCreationParams
extends PlatformWebAuthenticationSessionCreationParams {
/// Creates a new [MacOSWebAuthenticationSessionCreationParams] instance.
const MacOSWebAuthenticationSessionCreationParams();
/// Creates a [MacOSWebAuthenticationSessionCreationParams] instance based on [PlatformWebAuthenticationSessionCreationParams].
factory MacOSWebAuthenticationSessionCreationParams.fromPlatformWebAuthenticationSessionCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformWebAuthenticationSessionCreationParams params) {
return MacOSWebAuthenticationSessionCreationParams();
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession}
class MacOSWebAuthenticationSession extends PlatformWebAuthenticationSession
with ChannelController {
/// Constructs a [MacOSWebAuthenticationSession].
MacOSWebAuthenticationSession(
PlatformWebAuthenticationSessionCreationParams params)
: super.implementation(
params is MacOSWebAuthenticationSessionCreationParams
? params
: MacOSWebAuthenticationSessionCreationParams
.fromPlatformWebAuthenticationSessionCreationParams(params),
);
static final MacOSWebAuthenticationSession _staticValue =
MacOSWebAuthenticationSession(MacOSWebAuthenticationSessionCreationParams());
/// Provide static access.
factory MacOSWebAuthenticationSession.static() {
return _staticValue;
}
@override
final String id = IdGenerator.generate();
@override
late final WebUri url;
@override
late final String? callbackURLScheme;
@override
late final WebAuthenticationSessionSettings? initialSettings;
@override
late final WebAuthenticationSessionCompletionHandler onComplete;
static const MethodChannel _staticChannel = const MethodChannel(
'com.pichillilorenzo/flutter_webauthenticationsession');
@override
Future<MacOSWebAuthenticationSession> create(
{required WebUri url,
String? callbackURLScheme,
WebAuthenticationSessionCompletionHandler onComplete,
WebAuthenticationSessionSettings? initialSettings}) async {
var session = MacOSWebAuthenticationSession._create(
url: url,
callbackURLScheme: callbackURLScheme,
onComplete: onComplete,
initialSettings: initialSettings);
initialSettings =
session.initialSettings ?? WebAuthenticationSessionSettings();
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("id", () => session.id);
args.putIfAbsent("url", () => session.url.toString());
args.putIfAbsent("callbackURLScheme", () => session.callbackURLScheme);
args.putIfAbsent("initialSettings", () => initialSettings?.toMap());
await _staticChannel.invokeMethod('create', args);
return session;
}
MacOSWebAuthenticationSession._create(
{required this.url,
this.callbackURLScheme,
this.onComplete,
WebAuthenticationSessionSettings? initialSettings})
: super.implementation(MacOSWebAuthenticationSessionCreationParams()) {
assert(url.toString().isNotEmpty);
if (Util.isMacOS || Util.isMacOS) {
assert(['http', 'https'].contains(url.scheme),
'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.');
}
this.initialSettings =
initialSettings ?? WebAuthenticationSessionSettings();
channel = MethodChannel(
'com.pichillilorenzo/flutter_webauthenticationsession_$id');
handler = _handleMethod;
initMethodCallHandler();
}
_debugLog(String method, dynamic args) {
debugLog(
className: this.runtimeType.toString(),
debugLoggingSettings:
PlatformWebAuthenticationSession.debugLoggingSettings,
id: id,
method: method,
args: args);
}
Future<dynamic> _handleMethod(MethodCall call) async {
_debugLog(call.method, call.arguments);
switch (call.method) {
case "onComplete":
String? url = call.arguments["url"];
WebUri? uri = url != null ? WebUri(url) : null;
var error = WebAuthenticationSessionError.fromNativeValue(
call.arguments["errorCode"]);
if (onComplete != null) {
onComplete!(uri, error);
}
break;
default:
throw UnimplementedError("Unimplemented ${call.method} method");
}
}
@override
Future<bool> canStart() async {
Map<String, dynamic> args = <String, dynamic>{};
return await channel?.invokeMethod<bool>('canStart', args) ?? false;
}
@override
Future<bool> start() async {
Map<String, dynamic> args = <String, dynamic>{};
return await channel?.invokeMethod<bool>('start', args) ?? false;
}
@override
Future<void> cancel() async {
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod("cancel", args);
}
@override
Future<void> dispose() async {
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod("dispose", args);
disposeChannel();
}
@override
Future<bool> isAvailable() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _staticChannel.invokeMethod<bool>("isAvailable", args) ??
false;
}
}

View File

@ -0,0 +1,3 @@
export 'web_message_port.dart' hide InternalWebMessagePort;
export 'web_message_channel.dart' hide InternalWebMessageChannel;
export 'web_message_listener.dart';

View File

@ -0,0 +1,120 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import 'web_message_port.dart';
/// Object specifying creation parameters for creating a [MacOSWebMessageChannel].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformWebMessageChannelCreationParams] for
/// more information.
@immutable
class MacOSWebMessageChannelCreationParams
extends PlatformWebMessageChannelCreationParams {
/// Creates a new [MacOSWebMessageChannelCreationParams] instance.
const MacOSWebMessageChannelCreationParams(
{required super.id, required super.port1, required super.port2});
/// Creates a [MacOSWebMessageChannelCreationParams] instance based on [PlatformWebMessageChannelCreationParams].
factory MacOSWebMessageChannelCreationParams.fromPlatformWebMessageChannelCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformWebMessageChannelCreationParams params) {
return MacOSWebMessageChannelCreationParams(
id: params.id, port1: params.port1, port2: params.port2);
}
@override
String toString() {
return 'MacOSWebMessageChannelCreationParams{id: $id, port1: $port1, port2: $port2}';
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel}
class MacOSWebMessageChannel extends PlatformWebMessageChannel
with ChannelController {
/// Constructs a [MacOSWebMessageChannel].
MacOSWebMessageChannel(PlatformWebMessageChannelCreationParams params)
: super.implementation(
params is MacOSWebMessageChannelCreationParams
? params
: MacOSWebMessageChannelCreationParams
.fromPlatformWebMessageChannelCreationParams(params),
) {
channel = MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_web_message_channel_${params.id}');
handler = _handleMethod;
initMethodCallHandler();
}
static final MacOSWebMessageChannel _staticValue = MacOSWebMessageChannel(
MacOSWebMessageChannelCreationParams(
id: '',
port1: MacOSWebMessagePort(
MacOSWebMessagePortCreationParams(index: 0)),
port2: MacOSWebMessagePort(
MacOSWebMessagePortCreationParams(index: 1))));
/// Provide static access.
factory MacOSWebMessageChannel.static() {
return _staticValue;
}
MacOSWebMessagePort get _iosPort1 => port1 as MacOSWebMessagePort;
MacOSWebMessagePort get _iosPort2 => port2 as MacOSWebMessagePort;
static MacOSWebMessageChannel? _fromMap(Map<String, dynamic>? map) {
if (map == null) {
return null;
}
var webMessageChannel = MacOSWebMessageChannel(
MacOSWebMessageChannelCreationParams(
id: map["id"],
port1: MacOSWebMessagePort(
MacOSWebMessagePortCreationParams(index: 0)),
port2: MacOSWebMessagePort(
MacOSWebMessagePortCreationParams(index: 1))));
webMessageChannel._iosPort1.webMessageChannel = webMessageChannel;
webMessageChannel._iosPort2.webMessageChannel = webMessageChannel;
return webMessageChannel;
}
Future<dynamic> _handleMethod(MethodCall call) async {
switch (call.method) {
case "onMessage":
int index = call.arguments["index"];
var port = index == 0 ? _iosPort1 : _iosPort2;
if (port.onMessage != null) {
WebMessage? message = call.arguments["message"] != null
? WebMessage.fromMap(
call.arguments["message"].cast<String, dynamic>())
: null;
port.onMessage!(message);
}
break;
default:
throw UnimplementedError("Unimplemented ${call.method} method");
}
return null;
}
@override
MacOSWebMessageChannel? fromMap(Map<String, dynamic>? map) {
return _fromMap(map);
}
@override
void dispose() {
disposeChannel();
}
@override
String toString() {
return 'MacOSWebMessageChannel{id: $id, port1: $port1, port2: $port2}';
}
}
extension InternalWebMessageChannel on MacOSWebMessageChannel {
MethodChannel? get internalChannel => channel;
}

View File

@ -0,0 +1,164 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
/// Object specifying creation parameters for creating a [MacOSWebMessageListener].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformWebMessageListenerCreationParams] for
/// more information.
@immutable
class MacOSWebMessageListenerCreationParams
extends PlatformWebMessageListenerCreationParams {
/// Creates a new [MacOSWebMessageListenerCreationParams] instance.
const MacOSWebMessageListenerCreationParams(
{required this.allowedOriginRules,
required super.jsObjectName,
super.onPostMessage});
/// Creates a [MacOSWebMessageListenerCreationParams] instance based on [PlatformWebMessageListenerCreationParams].
factory MacOSWebMessageListenerCreationParams.fromPlatformWebMessageListenerCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformWebMessageListenerCreationParams params) {
return MacOSWebMessageListenerCreationParams(
allowedOriginRules: params.allowedOriginRules ?? Set.from(["*"]),
jsObjectName: params.jsObjectName,
onPostMessage: params.onPostMessage);
}
@override
final Set<String> allowedOriginRules;
@override
String toString() {
return 'MacOSWebMessageListenerCreationParams{jsObjectName: $jsObjectName, allowedOriginRules: $allowedOriginRules, onPostMessage: $onPostMessage}';
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener}
class MacOSWebMessageListener extends PlatformWebMessageListener
with ChannelController {
/// Constructs a [MacOSWebMessageListener].
MacOSWebMessageListener(PlatformWebMessageListenerCreationParams params)
: super.implementation(
params is MacOSWebMessageListenerCreationParams
? params
: MacOSWebMessageListenerCreationParams
.fromPlatformWebMessageListenerCreationParams(params),
) {
assert(!this._iosParams.allowedOriginRules.contains(""),
"allowedOriginRules cannot contain empty strings");
channel = MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_web_message_listener_${_id}_${params.jsObjectName}');
handler = _handleMethod;
initMethodCallHandler();
}
///Message Listener ID used internally.
final String _id = IdGenerator.generate();
MacOSJavaScriptReplyProxy? _replyProxy;
MacOSWebMessageListenerCreationParams get _iosParams =>
params as MacOSWebMessageListenerCreationParams;
Future<dynamic> _handleMethod(MethodCall call) async {
switch (call.method) {
case "onPostMessage":
if (_replyProxy == null) {
_replyProxy = MacOSJavaScriptReplyProxy(
PlatformJavaScriptReplyProxyCreationParams(
webMessageListener: this));
}
if (onPostMessage != null) {
WebMessage? message = call.arguments["message"] != null
? WebMessage.fromMap(
call.arguments["message"].cast<String, dynamic>())
: null;
WebUri? sourceOrigin = call.arguments["sourceOrigin"] != null
? WebUri(call.arguments["sourceOrigin"])
: null;
bool isMainFrame = call.arguments["isMainFrame"];
onPostMessage!(message, sourceOrigin, isMainFrame, _replyProxy!);
}
break;
default:
throw UnimplementedError("Unimplemented ${call.method} method");
}
return null;
}
@override
void dispose() {
disposeChannel();
}
@override
Map<String, dynamic> toMap() {
return {
"id": _id,
"jsObjectName": params.jsObjectName,
"allowedOriginRules": _iosParams.allowedOriginRules.toList(),
};
}
@override
Map<String, dynamic> toJson() {
return this.toMap();
}
@override
String toString() {
return 'MacOSWebMessageListener{id: ${_id}, jsObjectName: ${params.jsObjectName}, allowedOriginRules: ${params.allowedOriginRules}, replyProxy: $_replyProxy}';
}
}
/// Object specifying creation parameters for creating a [MacOSJavaScriptReplyProxy].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformJavaScriptReplyProxyCreationParams] for
/// more information.
@immutable
class MacOSJavaScriptReplyProxyCreationParams
extends PlatformJavaScriptReplyProxyCreationParams {
/// Creates a new [MacOSJavaScriptReplyProxyCreationParams] instance.
const MacOSJavaScriptReplyProxyCreationParams(
{required super.webMessageListener});
/// Creates a [MacOSJavaScriptReplyProxyCreationParams] instance based on [PlatformJavaScriptReplyProxyCreationParams].
factory MacOSJavaScriptReplyProxyCreationParams.fromPlatformJavaScriptReplyProxyCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformJavaScriptReplyProxyCreationParams params) {
return MacOSJavaScriptReplyProxyCreationParams(
webMessageListener: params.webMessageListener);
}
}
///{@macro flutter_inappwebview_platform_interface.JavaScriptReplyProxy}
class MacOSJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy {
/// Constructs a [MacOSWebMessageListener].
MacOSJavaScriptReplyProxy(PlatformJavaScriptReplyProxyCreationParams params)
: super.implementation(
params is MacOSJavaScriptReplyProxyCreationParams
? params
: MacOSJavaScriptReplyProxyCreationParams
.fromPlatformJavaScriptReplyProxyCreationParams(params),
);
MacOSWebMessageListener get _iosWebMessageListener =>
params.webMessageListener as MacOSWebMessageListener;
@override
Future<void> postMessage(WebMessage message) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('message', () => message.toMap());
await _iosWebMessageListener.channel?.invokeMethod('postMessage', args);
}
@override
String toString() {
return 'MacOSJavaScriptReplyProxy{}';
}
}

View File

@ -0,0 +1,95 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import 'web_message_channel.dart';
/// Object specifying creation parameters for creating a [MacOSWebMessagePort].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformWebMessagePortCreationParams] for
/// more information.
@immutable
class MacOSWebMessagePortCreationParams
extends PlatformWebMessagePortCreationParams {
/// Creates a new [MacOSWebMessagePortCreationParams] instance.
const MacOSWebMessagePortCreationParams({required super.index});
/// Creates a [MacOSWebMessagePortCreationParams] instance based on [PlatformWebMessagePortCreationParams].
factory MacOSWebMessagePortCreationParams.fromPlatformWebMessagePortCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformWebMessagePortCreationParams params) {
return MacOSWebMessagePortCreationParams(index: params.index);
}
@override
String toString() {
return 'MacOSWebMessagePortCreationParams{index: $index}';
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformWebMessagePort}
class MacOSWebMessagePort extends PlatformWebMessagePort {
WebMessageCallback? _onMessage;
late MacOSWebMessageChannel _webMessageChannel;
/// Constructs a [MacOSWebMessagePort].
MacOSWebMessagePort(PlatformWebMessagePortCreationParams params)
: super.implementation(
params is MacOSWebMessagePortCreationParams
? params
: MacOSWebMessagePortCreationParams
.fromPlatformWebMessagePortCreationParams(params),
);
@override
Future<void> setWebMessageCallback(WebMessageCallback? onMessage) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('index', () => params.index);
await _webMessageChannel.internalChannel
?.invokeMethod('setWebMessageCallback', args);
this._onMessage = onMessage;
}
@override
Future<void> postMessage(WebMessage message) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('index', () => params.index);
args.putIfAbsent('message', () => message.toMap());
await _webMessageChannel.internalChannel?.invokeMethod('postMessage', args);
}
@override
Future<void> close() async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('index', () => params.index);
await _webMessageChannel.internalChannel?.invokeMethod('close', args);
}
@override
Map<String, dynamic> toMap() {
return {
"index": params.index,
"webMessageChannelId": this._webMessageChannel.params.id
};
}
@override
Map<String, dynamic> toJson() {
return toMap();
}
@override
String toString() {
return 'MacOSWebMessagePort{index: ${params.index}}';
}
}
extension InternalWebMessagePort on MacOSWebMessagePort {
WebMessageCallback? get onMessage => _onMessage;
void set onMessage(WebMessageCallback? value) => _onMessage = value;
MacOSWebMessageChannel get webMessageChannel => _webMessageChannel;
void set webMessageChannel(MacOSWebMessageChannel value) =>
_webMessageChannel = value;
}

View File

@ -0,0 +1,2 @@
export 'web_storage.dart';
export 'web_storage_manager.dart' hide InternalWebStorageManager;

View File

@ -0,0 +1,257 @@
import 'dart:convert';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import '../in_app_webview/in_app_webview_controller.dart';
/// Object specifying creation parameters for creating a [MacOSWebStorage].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformWebStorageCreationParams] for
/// more information.
class MacOSWebStorageCreationParams extends PlatformWebStorageCreationParams {
/// Creates a new [MacOSWebStorageCreationParams] instance.
MacOSWebStorageCreationParams(
{required super.localStorage, required super.sessionStorage});
/// Creates a [MacOSWebStorageCreationParams] instance based on [PlatformWebStorageCreationParams].
factory MacOSWebStorageCreationParams.fromPlatformWebStorageCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformWebStorageCreationParams params) {
return MacOSWebStorageCreationParams(
localStorage: params.localStorage,
sessionStorage: params.sessionStorage);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage}
class MacOSWebStorage extends PlatformWebStorage {
/// Constructs a [MacOSWebStorage].
MacOSWebStorage(PlatformWebStorageCreationParams params)
: super.implementation(
params is MacOSWebStorageCreationParams
? params
: MacOSWebStorageCreationParams
.fromPlatformWebStorageCreationParams(params),
);
@override
PlatformLocalStorage get localStorage => params.localStorage;
@override
PlatformSessionStorage get sessionStorage => params.sessionStorage;
@override
void dispose() {
localStorage.dispose();
sessionStorage.dispose();
}
}
/// Object specifying creation parameters for creating a [MacOSStorage].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformStorageCreationParams] for
/// more information.
class MacOSStorageCreationParams extends PlatformStorageCreationParams {
/// Creates a new [MacOSStorageCreationParams] instance.
MacOSStorageCreationParams(
{required super.controller, required super.webStorageType});
/// Creates a [MacOSStorageCreationParams] instance based on [PlatformStorageCreationParams].
factory MacOSStorageCreationParams.fromPlatformStorageCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformStorageCreationParams params) {
return MacOSStorageCreationParams(
controller: params.controller, webStorageType: params.webStorageType);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
abstract class MacOSStorage implements PlatformStorage {
@override
MacOSInAppWebViewController? controller;
@override
Future<int?> length() async {
var result = await controller?.evaluateJavascript(source: """
window.$webStorageType.length;
""");
return result != null ? int.parse(json.decode(result)) : null;
}
@override
Future<void> setItem({required String key, required dynamic value}) async {
var encodedValue = json.encode(value);
await controller?.evaluateJavascript(source: """
window.$webStorageType.setItem("$key", ${value is String ? encodedValue : "JSON.stringify($encodedValue)"});
""");
}
@override
Future<dynamic> getItem({required String key}) async {
var itemValue = await controller?.evaluateJavascript(source: """
window.$webStorageType.getItem("$key");
""");
if (itemValue == null) {
return null;
}
try {
return json.decode(itemValue);
} catch (e) {}
return itemValue;
}
@override
Future<void> removeItem({required String key}) async {
await controller?.evaluateJavascript(source: """
window.$webStorageType.removeItem("$key");
""");
}
@override
Future<List<WebStorageItem>> getItems() async {
var webStorageItems = <WebStorageItem>[];
List<Map<dynamic, dynamic>>? items =
(await controller?.evaluateJavascript(source: """
(function() {
var webStorageItems = [];
for(var i = 0; i < window.$webStorageType.length; i++){
var key = window.$webStorageType.key(i);
webStorageItems.push(
{
key: key,
value: window.$webStorageType.getItem(key)
}
);
}
return webStorageItems;
})();
"""))?.cast<Map<dynamic, dynamic>>();
if (items == null) {
return webStorageItems;
}
for (var item in items) {
webStorageItems
.add(WebStorageItem(key: item["key"], value: item["value"]));
}
return webStorageItems;
}
@override
Future<void> clear() async {
await controller?.evaluateJavascript(source: """
window.$webStorageType.clear();
""");
}
@override
Future<String> key({required int index}) async {
var result = await controller?.evaluateJavascript(source: """
window.$webStorageType.key($index);
""");
return result != null ? json.decode(result) : null;
}
@override
void dispose() {
controller = null;
}
}
/// Object specifying creation parameters for creating a [MacOSLocalStorage].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformLocalStorageCreationParams] for
/// more information.
class MacOSLocalStorageCreationParams
extends PlatformLocalStorageCreationParams {
/// Creates a new [MacOSLocalStorageCreationParams] instance.
MacOSLocalStorageCreationParams(super.params);
/// Creates a [MacOSLocalStorageCreationParams] instance based on [PlatformLocalStorageCreationParams].
factory MacOSLocalStorageCreationParams.fromPlatformLocalStorageCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformLocalStorageCreationParams params) {
return MacOSLocalStorageCreationParams(params);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
class MacOSLocalStorage extends PlatformLocalStorage with MacOSStorage {
/// Constructs a [MacOSLocalStorage].
MacOSLocalStorage(PlatformLocalStorageCreationParams params)
: super.implementation(
params is MacOSLocalStorageCreationParams
? params
: MacOSLocalStorageCreationParams
.fromPlatformLocalStorageCreationParams(params),
);
/// Default storage
factory MacOSLocalStorage.defaultStorage(
{required PlatformInAppWebViewController? controller}) {
return MacOSLocalStorage(MacOSLocalStorageCreationParams(
PlatformLocalStorageCreationParams(PlatformStorageCreationParams(
controller: controller,
webStorageType: WebStorageType.LOCAL_STORAGE))));
}
@override
MacOSInAppWebViewController? get controller =>
params.controller as MacOSInAppWebViewController?;
}
/// Object specifying creation parameters for creating a [MacOSSessionStorage].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformSessionStorageCreationParams] for
/// more information.
class MacOSSessionStorageCreationParams
extends PlatformSessionStorageCreationParams {
/// Creates a new [MacOSSessionStorageCreationParams] instance.
MacOSSessionStorageCreationParams(super.params);
/// Creates a [MacOSSessionStorageCreationParams] instance based on [PlatformSessionStorageCreationParams].
factory MacOSSessionStorageCreationParams.fromPlatformSessionStorageCreationParams(
// Recommended placeholder to prevent being broken by platform interface.
// ignore: avoid_unused_constructor_parameters
PlatformSessionStorageCreationParams params) {
return MacOSSessionStorageCreationParams(params);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
class MacOSSessionStorage extends PlatformSessionStorage with MacOSStorage {
/// Constructs a [MacOSSessionStorage].
MacOSSessionStorage(PlatformSessionStorageCreationParams params)
: super.implementation(
params is MacOSSessionStorageCreationParams
? params
: MacOSSessionStorageCreationParams
.fromPlatformSessionStorageCreationParams(params),
);
/// Default storage
factory MacOSSessionStorage.defaultStorage(
{required PlatformInAppWebViewController? controller}) {
return MacOSSessionStorage(MacOSSessionStorageCreationParams(
PlatformSessionStorageCreationParams(PlatformStorageCreationParams(
controller: controller,
webStorageType: WebStorageType.SESSION_STORAGE))));
}
@override
MacOSInAppWebViewController? get controller =>
params.controller as MacOSInAppWebViewController?;
}

View File

@ -0,0 +1,134 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
/// Object specifying creation parameters for creating a [MacOSWebStorageManager].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformWebStorageManagerCreationParams] for
/// more information.
@immutable
class MacOSWebStorageManagerCreationParams
extends PlatformWebStorageManagerCreationParams {
/// Creates a new [MacOSWebStorageManagerCreationParams] instance.
const MacOSWebStorageManagerCreationParams(
// This parameter prevents breaking changes later.
// ignore: avoid_unused_constructor_parameters
PlatformWebStorageManagerCreationParams params,
) : super();
/// Creates a [MacOSWebStorageManagerCreationParams] instance based on [PlatformWebStorageManagerCreationParams].
factory MacOSWebStorageManagerCreationParams.fromPlatformWebStorageManagerCreationParams(
PlatformWebStorageManagerCreationParams params) {
return MacOSWebStorageManagerCreationParams(params);
}
}
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager}
class MacOSWebStorageManager extends PlatformWebStorageManager
with ChannelController {
/// Creates a new [MacOSWebStorageManager].
MacOSWebStorageManager(PlatformWebStorageManagerCreationParams params)
: super.implementation(
params is MacOSWebStorageManagerCreationParams
? params
: MacOSWebStorageManagerCreationParams
.fromPlatformWebStorageManagerCreationParams(params),
) {
channel = const MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_webstoragemanager');
handler = handleMethod;
initMethodCallHandler();
}
static MacOSWebStorageManager? _instance;
///Gets the WebStorage manager shared instance.
static MacOSWebStorageManager instance() {
return (_instance != null) ? _instance! : _init();
}
static MacOSWebStorageManager _init() {
_instance = MacOSWebStorageManager(MacOSWebStorageManagerCreationParams(
const PlatformWebStorageManagerCreationParams()));
return _instance!;
}
Future<dynamic> _handleMethod(MethodCall call) async {}
@override
Future<List<WebsiteDataRecord>> fetchDataRecords(
{required Set<WebsiteDataType> dataTypes}) async {
List<WebsiteDataRecord> recordList = [];
List<String> dataTypesList = [];
for (var dataType in dataTypes) {
dataTypesList.add(dataType.toNativeValue());
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("dataTypes", () => dataTypesList);
List<Map<dynamic, dynamic>> records =
(await channel?.invokeMethod<List>('fetchDataRecords', args))
?.cast<Map<dynamic, dynamic>>() ??
[];
for (var record in records) {
List<String> dataTypesString = record["dataTypes"].cast<String>();
Set<WebsiteDataType> dataTypes = Set();
for (var dataTypeValue in dataTypesString) {
var dataType = WebsiteDataType.fromNativeValue(dataTypeValue);
if (dataType != null) {
dataTypes.add(dataType);
}
}
recordList.add(WebsiteDataRecord(
displayName: record["displayName"], dataTypes: dataTypes));
}
return recordList;
}
@override
Future<void> removeDataFor(
{required Set<WebsiteDataType> dataTypes,
required List<WebsiteDataRecord> dataRecords}) async {
List<String> dataTypesList = [];
for (var dataType in dataTypes) {
dataTypesList.add(dataType.toNativeValue());
}
List<Map<String, dynamic>> recordList = [];
for (var record in dataRecords) {
recordList.add(record.toMap());
}
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("dataTypes", () => dataTypesList);
args.putIfAbsent("recordList", () => recordList);
await channel?.invokeMethod('removeDataFor', args);
}
@override
Future<void> removeDataModifiedSince(
{required Set<WebsiteDataType> dataTypes, required DateTime date}) async {
List<String> dataTypesList = [];
for (var dataType in dataTypes) {
dataTypesList.add(dataType.toNativeValue());
}
var timestamp = date.millisecondsSinceEpoch;
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("dataTypes", () => dataTypesList);
args.putIfAbsent("timestamp", () => timestamp);
await channel?.invokeMethod('removeDataModifiedSince', args);
}
@override
void dispose() {
// empty
}
}
extension InternalWebStorageManager on MacOSWebStorageManager {
get handleMethod => _handleMethod;
}

Some files were not shown because too many files have changed in this diff Show More