Merge branch 'feature/flutter_inappwebview_windows'

This commit is contained in:
unknown 2024-01-31 14:20:38 +01:00
commit a6b9a959e1
241 changed files with 20237 additions and 230 deletions

75
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,75 @@
{
"cmake.configureOnOpen": false,
"files.associations": {
"algorithm": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"coroutine": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"format": "cpp",
"forward_list": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"set": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"variant": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}

View File

@ -140,6 +140,7 @@ class ExchangeableEnumGenerator
<DartObject>[];
var hasWebSupport = false;
var webSupportValue = null;
var allPlatformsWithoutValue = true;
if (platforms.isNotEmpty) {
for (var platform in platforms) {
final targetPlatformName =
@ -150,6 +151,9 @@ class ExchangeableEnumGenerator
? platformValueField.toIntValue() ??
"'${platformValueField.toStringValue()}'"
: null;
if (allPlatformsWithoutValue && platformValue != null) {
allPlatformsWithoutValue = false;
}
if (targetPlatformName == "web") {
hasWebSupport = true;
webSupportValue = platformValue;
@ -170,8 +174,13 @@ class ExchangeableEnumGenerator
nativeValueBody += "return $defaultValue;";
nativeValueBody += "}";
classBuffer.writeln(
"static final $fieldName = $extClassName._internalMultiPlatform($constantValue, $nativeValueBody);");
if (!allPlatformsWithoutValue) {
classBuffer.writeln(
"static final $fieldName = $extClassName._internalMultiPlatform($constantValue, $nativeValueBody);");
} else {
classBuffer.writeln(
"static const $fieldName = $extClassName._internal($constantValue, ${defaultValue ?? constantValue});");
}
} else {
classBuffer.writeln(
"static const $fieldName = $extClassName._internal($constantValue, $constantValue);");

View File

@ -4,5 +4,27 @@
# This file should be version controlled and should not be manually edited.
version:
revision: d927c9331005f81157fa39dff7b5dab415ad330b
channel: master
revision: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9"
channel: "stable"
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: windows
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
# 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

@ -24,6 +24,7 @@ class _HeadlessInAppWebViewExampleScreenState
: WebUri("http://localhost:${Uri.base.port}/page.html");
headlessWebView = HeadlessInAppWebView(
webViewEnvironment: webViewEnvironment,
initialUrlRequest: URLRequest(url: url),
initialSettings: InAppWebViewSettings(
isInspectable: kDebugMode,

View File

@ -17,7 +17,8 @@ class MyInAppBrowser extends InAppBrowser {
: super(
windowId: windowId,
initialUserScripts: initialUserScripts,
pullToRefreshController: pullToRefreshController);
pullToRefreshController: pullToRefreshController,
webViewEnvironment: webViewEnvironment,);
@override
Future onBrowserCreated() async {

View File

@ -115,6 +115,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
children: [
InAppWebView(
key: webViewKey,
webViewEnvironment: webViewEnvironment,
initialUrlRequest:
URLRequest(url: WebUri('https://flutter.dev')),
// initialUrlRequest:

View File

@ -15,6 +15,7 @@ import 'package:pointer_interceptor/pointer_interceptor.dart';
// import 'package:permission_handler/permission_handler.dart';
final localhostServer = InAppLocalhostServer(documentRoot: 'assets');
WebViewEnvironment? webViewEnvironment;
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
@ -22,12 +23,18 @@ Future main() async {
// await Permission.microphone.request();
// await Permission.storage.request();
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
await InAppWebViewController.setWebContentsDebuggingEnabled(kDebugMode);
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) {
final availableVersion = await WebViewEnvironment.getAvailableVersion();
assert(availableVersion != null, 'Failed to find an installed WebView2 runtime or non-stable Microsoft Edge installation.');
webViewEnvironment = await WebViewEnvironment.create(settings:
WebViewEnvironmentSettings(
userDataFolder: 'custom_path'
));
}
if (!kIsWeb) {
await localhostServer.start();
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
await InAppWebViewController.setWebContentsDebuggingEnabled(kDebugMode);
}
runApp(MyApp());
@ -108,6 +115,28 @@ PointerInterceptor myDrawer({required BuildContext context}) {
},
),
];
} else if (defaultTargetPlatform == TargetPlatform.windows ||
defaultTargetPlatform == TargetPlatform.linux) {
children = [
ListTile(
title: Text('InAppWebView'),
onTap: () {
Navigator.pushReplacementNamed(context, '/');
},
),
ListTile(
title: Text('InAppBrowser'),
onTap: () {
Navigator.pushReplacementNamed(context, '/InAppBrowser');
},
),
ListTile(
title: Text('HeadlessInAppWebView'),
onTap: () {
Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView');
},
),
];
}
return PointerInterceptor(
child: Drawer(
@ -160,6 +189,14 @@ class _MyAppState extends State<MyApp> {
'/WebAuthenticationSession': (context) =>
WebAuthenticationSessionExampleScreen(),
});
} else if (defaultTargetPlatform == TargetPlatform.windows ||
defaultTargetPlatform == TargetPlatform.linux) {
return MaterialApp(initialRoute: '/', routes: {
'/': (context) => InAppWebViewExampleScreen(),
'/InAppBrowser': (context) => InAppBrowserExampleScreen(),
'/HeadlessInAppWebView': (context) =>
HeadlessInAppWebViewExampleScreen(),
});
}
return MaterialApp(initialRoute: '/', routes: {
'/': (context) => InAppWebViewExampleScreen(),

View File

@ -43,6 +43,8 @@ dependency_overrides:
path: ../../flutter_inappwebview_macos
flutter_inappwebview_web:
path: ../../flutter_inappwebview_web
flutter_inappwebview_windows:
path: ../../flutter_inappwebview_windows
dev_dependencies:
flutter_test:

View File

@ -0,0 +1,30 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:example/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}

View File

@ -0,0 +1,19 @@
flutter/ephemeral/
# Visual Studio user-specific files.
*.suo
*.user
*.userosscache
*.sln.docstates
# Visual Studio build-related files.
x64/
x86/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
cmake-build-*

View File

@ -0,0 +1,108 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(example LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "example")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(VERSION 3.14...3.25)
# Define build configuration option.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
endif()
# Define settings for the Profile build mode.
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
# Use Unicode for all projects.
add_definitions(-DUNICODE -D_UNICODE)
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
endfunction()
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)

View File

@ -0,0 +1,109 @@
# This file controls Flutter-level build steps. It should not be edited.
cmake_minimum_required(VERSION 3.14)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()
# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"flutter_export.h"
"flutter_windows.h"
"flutter_messenger.h"
"flutter_plugin_registrar.h"
"flutter_texture_registrar.h"
)
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
add_dependencies(flutter flutter_assemble)
# === Wrapper ===
list(APPEND CPP_WRAPPER_SOURCES_CORE
"core_implementations.cc"
"standard_codec.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
"plugin_registrar.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
list(APPEND CPP_WRAPPER_SOURCES_APP
"flutter_engine.cc"
"flutter_view_controller.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
# Wrapper sources needed for a plugin.
add_library(flutter_wrapper_plugin STATIC
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
)
apply_standard_settings(flutter_wrapper_plugin)
set_target_properties(flutter_wrapper_plugin PROPERTIES
POSITION_INDEPENDENT_CODE ON)
set_target_properties(flutter_wrapper_plugin PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
target_include_directories(flutter_wrapper_plugin PUBLIC
"${WRAPPER_ROOT}/include"
)
add_dependencies(flutter_wrapper_plugin flutter_assemble)
# Wrapper sources needed for the runner.
add_library(flutter_wrapper_app STATIC
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_APP}
)
apply_standard_settings(flutter_wrapper_app)
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
target_include_directories(flutter_wrapper_app PUBLIC
"${WRAPPER_ROOT}/include"
)
add_dependencies(flutter_wrapper_app flutter_assemble)
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
${CPP_WRAPPER_SOURCES_APP}
${PHONY_OUTPUT}
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
${CPP_WRAPPER_SOURCES_APP}
)

View File

@ -0,0 +1,20 @@
//
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

View File

@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter/plugin_registry.h>
// Registers Flutter plugins.
void RegisterPlugins(flutter::PluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_

View File

@ -0,0 +1,26 @@
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
flutter_inappwebview_windows
permission_handler_windows
url_launcher_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
"utils.cpp"
"win32_window.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
"Runner.rc"
"runner.exe.manifest"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)

View File

@ -0,0 +1,121 @@
// Microsoft Visual C++ generated resource script.
//
#pragma code_page(65001)
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APP_ICON ICON "resources\\app_icon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0,0
#endif
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_AS_NUMBER
PRODUCTVERSION VERSION_AS_NUMBER
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.pichillilorenzo" "\0"
VALUE "FileDescription", "example" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "example" "\0"
VALUE "LegalCopyright", "Copyright (C) 2023 com.pichillilorenzo. All rights reserved." "\0"
VALUE "OriginalFilename", "example.exe" "\0"
VALUE "ProductName", "example" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,71 @@
#include "flutter_window.h"
#include <optional>
#include "flutter/generated_plugin_registrant.h"
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
: project_(project) {}
FlutterWindow::~FlutterWindow() {}
bool FlutterWindow::OnCreate() {
if (!Win32Window::OnCreate()) {
return false;
}
RECT frame = GetClientArea();
// The size here must match the window dimensions to avoid unnecessary surface
// creation / destruction in the startup path.
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
frame.right - frame.left, frame.bottom - frame.top, project_);
// Ensure that basic setup of the controller was successful.
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
return false;
}
RegisterPlugins(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());
flutter_controller_->engine()->SetNextFrameCallback([&]() {
this->Show();
});
// Flutter can complete the first frame before the "show window" callback is
// registered. The following call ensures a frame is pending to ensure the
// window is shown. It is a no-op if the first frame hasn't completed yet.
flutter_controller_->ForceRedraw();
return true;
}
void FlutterWindow::OnDestroy() {
if (flutter_controller_) {
flutter_controller_ = nullptr;
}
Win32Window::OnDestroy();
}
LRESULT
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
// Give Flutter, including plugins, an opportunity to handle window messages.
if (flutter_controller_) {
std::optional<LRESULT> result =
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
lparam);
if (result) {
return *result;
}
}
switch (message) {
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
}
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
}

View File

@ -0,0 +1,33 @@
#ifndef RUNNER_FLUTTER_WINDOW_H_
#define RUNNER_FLUTTER_WINDOW_H_
#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
#include <memory>
#include "win32_window.h"
// A window that does nothing but host a Flutter view.
class FlutterWindow : public Win32Window {
public:
// Creates a new FlutterWindow hosting a Flutter view running |project|.
explicit FlutterWindow(const flutter::DartProject& project);
virtual ~FlutterWindow();
protected:
// Win32Window:
bool OnCreate() override;
void OnDestroy() override;
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
LPARAM const lparam) noexcept override;
private:
// The project to run.
flutter::DartProject project_;
// The Flutter instance hosted by this window.
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
};
#endif // RUNNER_FLUTTER_WINDOW_H_

View File

@ -0,0 +1,43 @@
#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
#include <windows.h>
#include "flutter_window.h"
#include "utils.h"
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
CreateAndAttachConsole();
}
// Initialize COM, so that it is available for use in the library and/or
// plugins.
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
flutter::DartProject project(L"data");
std::vector<std::string> command_line_arguments =
GetCommandLineArguments();
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.Create(L"example", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);
::MSG msg;
while (::GetMessage(&msg, nullptr, 0, 0)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
::CoUninitialize();
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Runner.rc
//
#define IDI_APP_ICON 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>

View File

@ -0,0 +1,65 @@
#include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
_dup2(_fileno(stdout), 2);
}
std::ios::sync_with_stdio();
FlutterDesktopResyncOutputStreams();
}
}
std::vector<std::string> GetCommandLineArguments() {
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
int argc;
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
if (argv == nullptr) {
return std::vector<std::string>();
}
std::vector<std::string> command_line_arguments;
// Skip the first argument as it's the binary name.
for (int i = 1; i < argc; i++) {
command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
}
::LocalFree(argv);
return command_line_arguments;
}
std::string Utf8FromUtf16(const wchar_t* utf16_string) {
if (utf16_string == nullptr) {
return std::string();
}
int target_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
-1, nullptr, 0, nullptr, nullptr)
-1; // remove the trailing null character
int input_length = (int)wcslen(utf16_string);
std::string utf8_string;
if (target_length <= 0 || target_length > utf8_string.max_size()) {
return utf8_string;
}
utf8_string.resize(target_length);
int converted_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
input_length, utf8_string.data(), target_length, nullptr, nullptr);
if (converted_length == 0) {
return std::string();
}
return utf8_string;
}

View File

@ -0,0 +1,19 @@
#ifndef RUNNER_UTILS_H_
#define RUNNER_UTILS_H_
#include <string>
#include <vector>
// Creates a console for the process, and redirects stdout and stderr to
// it for both the runner and the Flutter library.
void CreateAndAttachConsole();
// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
// encoded in UTF-8. Returns an empty std::string on failure.
std::string Utf8FromUtf16(const wchar_t* utf16_string);
// Gets the command line arguments passed in as a std::vector<std::string>,
// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
std::vector<std::string> GetCommandLineArguments();
#endif // RUNNER_UTILS_H_

View File

@ -0,0 +1,288 @@
#include "win32_window.h"
#include <dwmapi.h>
#include <flutter_windows.h>
#include "resource.h"
namespace {
/// Window attribute that enables dark mode window decorations.
///
/// Redefined in case the developer's machine has a Windows SDK older than
/// version 10.0.22000.0.
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
#endif
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
/// Registry key for app theme preference.
///
/// A value of 0 indicates apps should use dark mode. A non-zero or missing
/// value indicates apps should use light mode.
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
// The number of Win32Window objects that currently exist.
static int g_active_window_count = 0;
using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
// Scale helper to convert logical scaler values to physical using passed in
// scale factor
int Scale(int source, double scale_factor) {
return static_cast<int>(source * scale_factor);
}
// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
// This API is only needed for PerMonitor V1 awareness mode.
void EnableFullDpiSupportIfAvailable(HWND hwnd) {
HMODULE user32_module = LoadLibraryA("User32.dll");
if (!user32_module) {
return;
}
auto enable_non_client_dpi_scaling =
reinterpret_cast<EnableNonClientDpiScaling*>(
GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
if (enable_non_client_dpi_scaling != nullptr) {
enable_non_client_dpi_scaling(hwnd);
}
FreeLibrary(user32_module);
}
} // namespace
// Manages the Win32Window's window class registration.
class WindowClassRegistrar {
public:
~WindowClassRegistrar() = default;
// Returns the singleton registrar instance.
static WindowClassRegistrar* GetInstance() {
if (!instance_) {
instance_ = new WindowClassRegistrar();
}
return instance_;
}
// Returns the name of the window class, registering the class if it hasn't
// previously been registered.
const wchar_t* GetWindowClass();
// Unregisters the window class. Should only be called if there are no
// instances of the window.
void UnregisterWindowClass();
private:
WindowClassRegistrar() = default;
static WindowClassRegistrar* instance_;
bool class_registered_ = false;
};
WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
const wchar_t* WindowClassRegistrar::GetWindowClass() {
if (!class_registered_) {
WNDCLASS window_class{};
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
window_class.lpszClassName = kWindowClassName;
window_class.style = CS_HREDRAW | CS_VREDRAW;
window_class.cbClsExtra = 0;
window_class.cbWndExtra = 0;
window_class.hInstance = GetModuleHandle(nullptr);
window_class.hIcon =
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
window_class.hbrBackground = 0;
window_class.lpszMenuName = nullptr;
window_class.lpfnWndProc = Win32Window::WndProc;
RegisterClass(&window_class);
class_registered_ = true;
}
return kWindowClassName;
}
void WindowClassRegistrar::UnregisterWindowClass() {
UnregisterClass(kWindowClassName, nullptr);
class_registered_ = false;
}
Win32Window::Win32Window() {
++g_active_window_count;
}
Win32Window::~Win32Window() {
--g_active_window_count;
Destroy();
}
bool Win32Window::Create(const std::wstring& title,
const Point& origin,
const Size& size) {
Destroy();
const wchar_t* window_class =
WindowClassRegistrar::GetInstance()->GetWindowClass();
const POINT target_point = {static_cast<LONG>(origin.x),
static_cast<LONG>(origin.y)};
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
double scale_factor = dpi / 96.0;
HWND window = CreateWindow(
window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
nullptr, nullptr, GetModuleHandle(nullptr), this);
if (!window) {
return false;
}
UpdateTheme(window);
return OnCreate();
}
bool Win32Window::Show() {
return ShowWindow(window_handle_, SW_SHOWNORMAL);
}
// static
LRESULT CALLBACK Win32Window::WndProc(HWND const window,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
if (message == WM_NCCREATE) {
auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
SetWindowLongPtr(window, GWLP_USERDATA,
reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
EnableFullDpiSupportIfAvailable(window);
that->window_handle_ = window;
} else if (Win32Window* that = GetThisFromHandle(window)) {
return that->MessageHandler(window, message, wparam, lparam);
}
return DefWindowProc(window, message, wparam, lparam);
}
LRESULT
Win32Window::MessageHandler(HWND hwnd,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
switch (message) {
case WM_DESTROY:
window_handle_ = nullptr;
Destroy();
if (quit_on_close_) {
PostQuitMessage(0);
}
return 0;
case WM_DPICHANGED: {
auto newRectSize = reinterpret_cast<RECT*>(lparam);
LONG newWidth = newRectSize->right - newRectSize->left;
LONG newHeight = newRectSize->bottom - newRectSize->top;
SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
return 0;
}
case WM_SIZE: {
RECT rect = GetClientArea();
if (child_content_ != nullptr) {
// Size and position the child window.
MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
rect.bottom - rect.top, TRUE);
}
return 0;
}
case WM_ACTIVATE:
if (child_content_ != nullptr) {
SetFocus(child_content_);
}
return 0;
case WM_DWMCOLORIZATIONCOLORCHANGED:
UpdateTheme(hwnd);
return 0;
}
return DefWindowProc(window_handle_, message, wparam, lparam);
}
void Win32Window::Destroy() {
OnDestroy();
if (window_handle_) {
DestroyWindow(window_handle_);
window_handle_ = nullptr;
}
if (g_active_window_count == 0) {
WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
}
}
Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
return reinterpret_cast<Win32Window*>(
GetWindowLongPtr(window, GWLP_USERDATA));
}
void Win32Window::SetChildContent(HWND content) {
child_content_ = content;
SetParent(content, window_handle_);
RECT frame = GetClientArea();
MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
frame.bottom - frame.top, true);
SetFocus(child_content_);
}
RECT Win32Window::GetClientArea() {
RECT frame;
GetClientRect(window_handle_, &frame);
return frame;
}
HWND Win32Window::GetHandle() {
return window_handle_;
}
void Win32Window::SetQuitOnClose(bool quit_on_close) {
quit_on_close_ = quit_on_close;
}
bool Win32Window::OnCreate() {
// No-op; provided for subclasses.
return true;
}
void Win32Window::OnDestroy() {
// No-op; provided for subclasses.
}
void Win32Window::UpdateTheme(HWND const window) {
DWORD light_mode;
DWORD light_mode_size = sizeof(light_mode);
LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
kGetPreferredBrightnessRegValue,
RRF_RT_REG_DWORD, nullptr, &light_mode,
&light_mode_size);
if (result == ERROR_SUCCESS) {
BOOL enable_dark_mode = light_mode == 0;
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
&enable_dark_mode, sizeof(enable_dark_mode));
}
}

View File

@ -0,0 +1,102 @@
#ifndef RUNNER_WIN32_WINDOW_H_
#define RUNNER_WIN32_WINDOW_H_
#include <windows.h>
#include <functional>
#include <memory>
#include <string>
// A class abstraction for a high DPI-aware Win32 Window. Intended to be
// inherited from by classes that wish to specialize with custom
// rendering and input handling
class Win32Window {
public:
struct Point {
unsigned int x;
unsigned int y;
Point(unsigned int x, unsigned int y) : x(x), y(y) {}
};
struct Size {
unsigned int width;
unsigned int height;
Size(unsigned int width, unsigned int height)
: width(width), height(height) {}
};
Win32Window();
virtual ~Win32Window();
// Creates a win32 window with |title| that is positioned and sized using
// |origin| and |size|. New windows are created on the default monitor. Window
// sizes are specified to the OS in physical pixels, hence to ensure a
// consistent size this function will scale the inputted width and height as
// as appropriate for the default monitor. The window is invisible until
// |Show| is called. Returns true if the window was created successfully.
bool Create(const std::wstring& title, const Point& origin, const Size& size);
// Show the current window. Returns true if the window was successfully shown.
bool Show();
// Release OS resources associated with window.
void Destroy();
// Inserts |content| into the window tree.
void SetChildContent(HWND content);
// Returns the backing Window handle to enable clients to set icon and other
// window properties. Returns nullptr if the window has been destroyed.
HWND GetHandle();
// If true, closing this window will quit the application.
void SetQuitOnClose(bool quit_on_close);
// Return a RECT representing the bounds of the current client area.
RECT GetClientArea();
protected:
// Processes and route salient window messages for mouse handling,
// size change and DPI. Delegates handling of these to member overloads that
// inheriting classes can handle.
virtual LRESULT MessageHandler(HWND window,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept;
// Called when CreateAndShow is called, allowing subclass window-related
// setup. Subclasses should return false if setup fails.
virtual bool OnCreate();
// Called when Destroy is called.
virtual void OnDestroy();
private:
friend class WindowClassRegistrar;
// OS callback called by message pump. Handles the WM_NCCREATE message which
// is passed when the non-client area is being created and enables automatic
// non-client DPI scaling so that the non-client area automatically
// responds to changes in DPI. All other messages are handled by
// MessageHandler.
static LRESULT CALLBACK WndProc(HWND const window,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept;
// Retrieves a class instance pointer for |window|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
// Update the window frame's theme to match the system theme.
static void UpdateTheme(HWND const window);
bool quit_on_close_ = false;
// window handle for top level window.
HWND window_handle_ = nullptr;
// window handle for hosted content.
HWND child_content_ = nullptr;
};
#endif // RUNNER_WIN32_WINDOW_H_

View File

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import 'in_app_webview/in_app_webview_controller.dart';
import 'webview_environment/webview_environment.dart';
///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager}
class CookieManager {
@ -31,12 +32,22 @@ class CookieManager {
static CookieManager? _instance;
WebViewEnvironment? _webViewEnvironment;
///Gets the [CookieManager] shared instance.
static CookieManager instance() {
if (_instance == null) {
_instance = CookieManager();
///
///[webViewEnvironment] (Supported only on Windows) - Used to create the [CookieManager] using the specified environment.
static CookieManager instance({WebViewEnvironment? webViewEnvironment}) {
if (webViewEnvironment == null) {
if (_instance == null) {
_instance = CookieManager();
}
return _instance!;
} else {
return CookieManager.fromPlatformCreationParams(
PlatformCookieManagerCreationParams(webViewEnvironment: webViewEnvironment.platform)
);
}
return _instance!;
}
///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.setCookie}

View File

@ -11,6 +11,7 @@ import '../find_interaction/find_interaction_controller.dart';
import '../pull_to_refresh/main.dart';
import '../in_app_webview/in_app_webview_controller.dart';
import '../webview_environment/webview_environment.dart';
///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser}
class InAppBrowser implements PlatformInAppBrowserEvents {
@ -22,14 +23,17 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
PullToRefreshController? pullToRefreshController,
FindInteractionController? findInteractionController,
UnmodifiableListView<UserScript>? initialUserScripts,
int? windowId})
int? windowId,
WebViewEnvironment? webViewEnvironment,
})
: this.fromPlatformCreationParams(
PlatformInAppBrowserCreationParams(
contextMenu: contextMenu,
pullToRefreshController: pullToRefreshController?.platform,
findInteractionController: findInteractionController?.platform,
initialUserScripts: initialUserScripts,
windowId: windowId),
windowId: windowId,
webViewEnvironment: webViewEnvironment?.platform,),
);
/// Constructs a [InAppBrowser] from creation params for a specific

View File

@ -5,6 +5,7 @@ import 'dart:ui';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import '../find_interaction/find_interaction_controller.dart';
import '../webview_environment/webview_environment.dart';
import 'in_app_webview_controller.dart';
import '../pull_to_refresh/pull_to_refresh_controller.dart';
@ -42,6 +43,7 @@ class HeadlessInAppWebView {
HeadlessInAppWebView? headlessWebView,
InAppWebViewKeepAlive? keepAlive,
bool? preventGestureDelay,
WebViewEnvironment? webViewEnvironment,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead')
void Function(InAppWebViewController controller)?
androidOnGeolocationPermissionsHidePrompt,
@ -307,6 +309,7 @@ class HeadlessInAppWebView {
pullToRefreshController: pullToRefreshController?.platform,
findInteractionController: findInteractionController?.platform,
contextMenu: contextMenu,
webViewEnvironment: webViewEnvironment?.platform,
onWebViewCreated: onWebViewCreated != null
? (controller) => onWebViewCreated.call(controller)
: null,

View File

@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
import '../webview_environment/webview_environment.dart';
import 'headless_in_app_webview.dart';
import 'in_app_webview_controller.dart';
import '../find_interaction/find_interaction_controller.dart';
@ -42,6 +43,7 @@ class InAppWebView extends StatefulWidget {
InAppWebViewKeepAlive? keepAlive,
bool? preventGestureDelay,
TextDirection? layoutDirection,
WebViewEnvironment? webViewEnvironment,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead')
void Function(InAppWebViewController controller)?
androidOnGeolocationPermissionsHidePrompt,
@ -310,6 +312,7 @@ class InAppWebView extends StatefulWidget {
findInteractionController: findInteractionController?.platform,
contextMenu: contextMenu,
layoutDirection: layoutDirection,
webViewEnvironment: webViewEnvironment?.platform,
onWebViewCreated: onWebViewCreated != null
? (controller) => onWebViewCreated.call(controller)
: null,

View File

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

View File

@ -15,3 +15,4 @@ export 'webview_asset_loader.dart';
export 'tracing_controller.dart';
export 'process_global_config.dart';
export 'in_app_localhost_server.dart';
export 'webview_environment/main.dart';

View File

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

View File

@ -0,0 +1,43 @@
import 'dart:core';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment}
class WebViewEnvironment {
/// Constructs a [WebViewEnvironment].
///
/// See [WebViewEnvironment.fromPlatformCreationParams] for setting parameters for
/// a specific platform.
WebViewEnvironment.fromPlatformCreationParams({
required PlatformWebViewEnvironmentCreationParams params,
}) : this.fromPlatform(platform: PlatformWebViewEnvironment(params));
/// Constructs a [WebViewEnvironment] from a specific platform implementation.
WebViewEnvironment.fromPlatform({required this.platform});
/// Implementation of [PlatformWebViewEnvironment] for the current platform.
final PlatformWebViewEnvironment platform;
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.id}
String get id => platform.id;
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.settings}
WebViewEnvironmentSettings? get settings => platform.settings;
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.create}
static Future<WebViewEnvironment> create(
{WebViewEnvironmentSettings? settings}) async {
return WebViewEnvironment.fromPlatform(platform: await PlatformWebViewEnvironment.static().create(settings: settings));
}
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
static Future<String?> getAvailableVersion(
{String? browserExecutableFolder}) => PlatformWebViewEnvironment.static().getAvailableVersion(browserExecutableFolder: browserExecutableFolder);
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
static Future<int?> compareBrowserVersions(
{required String version1, required String version2}) => PlatformWebViewEnvironment.static().compareBrowserVersions(version1: version1, version2: version2);
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose}
Future<void> dispose() => platform.dispose();
}

View File

@ -81,7 +81,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.11"
version: "1.0.12"
flutter_inappwebview_internal_annotations:
dependency: transitive
description:

View File

@ -155,7 +155,7 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [AndroidWebStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [AndroidWebStorage] in `flutter_inappwebview` instead.
/// Look at using [WebStorage] in `flutter_inappwebview` instead.
@override
AndroidWebStorage createPlatformWebStorage(
PlatformWebStorageCreationParams params,
@ -166,7 +166,7 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [AndroidLocalStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [AndroidLocalStorage] in `flutter_inappwebview` instead.
/// Look at using [LocalStorage] in `flutter_inappwebview` instead.
@override
AndroidLocalStorage createPlatformLocalStorage(
PlatformLocalStorageCreationParams params,
@ -177,7 +177,7 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [AndroidSessionStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead.
/// Look at using [SessionStorage] in `flutter_inappwebview` instead.
@override
AndroidSessionStorage createPlatformSessionStorage(
PlatformSessionStorageCreationParams params,

View File

@ -150,7 +150,7 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [IOSWebStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [IOSWebStorage] in `flutter_inappwebview` instead.
/// Look at using [WebStorage] in `flutter_inappwebview` instead.
@override
IOSWebStorage createPlatformWebStorage(
PlatformWebStorageCreationParams params,
@ -161,7 +161,7 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [IOSLocalStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [IOSLocalStorage] in `flutter_inappwebview` instead.
/// Look at using [LocalStorage] in `flutter_inappwebview` instead.
@override
IOSLocalStorage createPlatformLocalStorage(
PlatformLocalStorageCreationParams params,
@ -172,7 +172,7 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [IOSSessionStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead.
/// Look at using [SessionStorage] in `flutter_inappwebview` instead.
@override
IOSSessionStorage createPlatformSessionStorage(
PlatformSessionStorageCreationParams params,

View File

@ -138,7 +138,7 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [MacOSWebStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [MacOSWebStorage] in `flutter_inappwebview` instead.
/// Look at using [WebStorage] in `flutter_inappwebview` instead.
@override
MacOSWebStorage createPlatformWebStorage(
PlatformWebStorageCreationParams params,
@ -149,7 +149,7 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [MacOSLocalStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [MacOSLocalStorage] in `flutter_inappwebview` instead.
/// Look at using [LocalStorage] in `flutter_inappwebview` instead.
@override
MacOSLocalStorage createPlatformLocalStorage(
PlatformLocalStorageCreationParams params,
@ -160,7 +160,7 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
/// Creates a new [MacOSSessionStorage].
///
/// This function should only be called by the app-facing package.
/// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead.
/// Look at using [SessionStorage] in `flutter_inappwebview` instead.
@override
MacOSSessionStorage createPlatformSessionStorage(
PlatformSessionStorageCreationParams params,

View File

@ -1,3 +1,7 @@
## 1.0.11
- Added `PlatformWebViewEnvironment` class
## 1.0.10
- Merged "Added == operator and hashCode to WebUri" [#1941](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1941) (thanks to [daisukeueta](https://github.com/daisukeueta))

View File

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

View File

@ -19,6 +19,7 @@ import '../in_app_webview/in_app_webview_settings.dart';
import '../print_job/main.dart';
import '../web_uri.dart';
import '../webview_environment/platform_webview_environment.dart';
import 'in_app_browser_menu_item.dart';
import 'in_app_browser_settings.dart';
import '../debug_logging_settings.dart';
@ -36,7 +37,9 @@ class PlatformInAppBrowserCreationParams {
this.pullToRefreshController,
this.findInteractionController,
this.initialUserScripts,
this.windowId});
this.windowId,
this.webViewEnvironment,
});
///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu}
final ContextMenu? contextMenu;
@ -52,6 +55,12 @@ class PlatformInAppBrowserCreationParams {
///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId}
final int? windowId;
///Used to create the [PlatformInAppBrowser] using the specified environment.
///
///**Officially Supported Platforms/Implementations**:
///- Windows
final PlatformWebViewEnvironment? webViewEnvironment;
}
///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser}
@ -64,6 +73,7 @@ class PlatformInAppBrowserCreationParams {
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
abstract class PlatformInAppBrowser extends PlatformInterface
implements Disposable {
@ -82,29 +92,53 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu}
///Context menu used by the browser. It should be set before opening the browser.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///{@endtemplate}
ContextMenu? get contextMenu => params.contextMenu;
///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.pullToRefreshController}
///Represents the pull-to-refresh feature controller.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///{@endtemplate}
PlatformPullToRefreshController? get pullToRefreshController =>
params.pullToRefreshController;
///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.findInteractionController}
///Represents the find interaction feature controller.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///{@endtemplate}
PlatformFindInteractionController? get findInteractionController =>
params.findInteractionController;
///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts}
///Initial list of user scripts to be loaded at start or end of a page loading.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
UnmodifiableListView<UserScript>? get initialUserScripts =>
params.initialUserScripts;
///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId}
///The window id of a [CreateWindowAction.windowId].
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///{@endtemplate}
int? get windowId => params.windowId;
@ -172,6 +206,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> openUrlRequest(
{required URLRequest urlRequest,
@ -225,6 +260,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> openFile(
{required String assetFilePath,
@ -252,6 +288,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> openData(
{required String data,
@ -274,6 +311,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> openWithSystemBrowser({required WebUri url}) {
throw UnimplementedError(
@ -370,6 +408,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> show() {
throw UnimplementedError('show is not implemented on the current platform');
@ -382,6 +421,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> hide() {
throw UnimplementedError('hide is not implemented on the current platform');
@ -394,6 +434,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> close() {
throw UnimplementedError(
@ -407,6 +448,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<bool> isHidden() {
throw UnimplementedError(
@ -464,6 +506,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
bool isOpened() {
throw UnimplementedError(
@ -487,6 +530,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView
///- iOS
///- MacOS
///- Windows
void onBrowserCreated() {}
///Event fired when the [PlatformInAppBrowser] window is closed.
@ -495,6 +539,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView
///- iOS
///- MacOS
///- Windows
void onExit() {}
///Event fired when the main window is about to close.
@ -509,6 +554,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- Windows ([Official API - ICoreWebView2.add_NavigationStarting](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationstarting))
void onLoadStart(WebUri? url) {}
///Event fired when the [PlatformInAppBrowser] finishes loading an [url].
@ -517,6 +563,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- Windows ([Official API - ICoreWebView2.add_NavigationCompleted](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted))
void onLoadStop(WebUri? url) {}
///Use [onReceivedError] instead.
@ -529,6 +576,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
///- Windows ([Official API - ICoreWebView2.add_NavigationCompleted](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted))
void onReceivedError(WebResourceRequest request, WebResourceError error) {}
///Use [onReceivedHttpError] instead.
@ -547,6 +595,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- Windows ([Official API - ICoreWebView2.add_NavigationCompleted](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted))
void onReceivedHttpError(
WebResourceRequest request, WebResourceResponse errorResponse) {}
@ -886,6 +935,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)))
///- iOS
///- MacOS
///- Windows ([Official API - ICoreWebView2.add_HistoryChanged](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_historychanged))
void onUpdateVisitedHistory(WebUri? url, bool? isReload) {}
///Use [onPrintRequest] instead
@ -955,6 +1005,7 @@ abstract class PlatformInAppBrowserEvents {
///- Android native WebView ([Official API - WebChromeClient.onReceivedTitle](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)))
///- iOS
///- MacOS
///- Windows ([Official API - ICoreWebView2.add_DocumentTitleChanged](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_documenttitlechanged))
void onTitleChanged(String? title) {}
///Event fired to respond to the results of an over-scroll operation.

View File

@ -28,12 +28,15 @@ class InAppWebViewControllerKeepAliveProps {
Map<String, ScriptHtmlTagAttributes> injectedScriptsFromURL;
Set<PlatformWebMessageChannel> webMessageChannels = Set();
Set<PlatformWebMessageListener> webMessageListeners = Set();
Map<String, Function(dynamic data)> devToolsProtocolEventListenerMap;
InAppWebViewControllerKeepAliveProps(
{required this.javaScriptHandlersMap,
required this.userScripts,
required this.webMessageListenerObjNames,
required this.injectedScriptsFromURL,
required this.webMessageChannels,
required this.webMessageListeners});
{this.javaScriptHandlersMap = const {},
this.userScripts = const {},
this.webMessageListenerObjNames = const {},
this.injectedScriptsFromURL = const {},
this.webMessageChannels = const {},
this.webMessageListeners = const {},
this.devToolsProtocolEventListenerMap = const {}
});
}

View File

@ -58,7 +58,7 @@ class InAppWebViewSettings_ {
///it will be automatically inferred as `true`, otherwise, the default value is `false`.
///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually.
@SupportedPlatforms(
platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()])
platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform(), WindowsPlatform()])
bool? useShouldOverrideUrlLoading;
///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onLoadResource] event.
@ -98,7 +98,11 @@ class InAppWebViewSettings_ {
MacOSPlatform(
apiName: "WKWebView.customUserAgent",
apiUrl:
"https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent")
"https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent"),
WindowsPlatform(
apiName: 'ICoreWebView2Settings2.put_UserAgent',
apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings2?view=webview2-1.0.2210.55#put_useragent'
)
])
String? userAgent;
@ -130,7 +134,12 @@ class InAppWebViewSettings_ {
apiName: "WKWebpagePreferences.allowsContentJavaScript",
apiUrl:
"https://developer.apple.com/documentation/webkit/wkwebpagepreferences/3552422-allowscontentjavascript/"),
WebPlatform(requiresSameOrigin: false)
WebPlatform(requiresSameOrigin: false),
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_IsScriptEnabled",
apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_isscriptenabled"
)
])
bool? javaScriptEnabled;
@ -307,7 +316,12 @@ because there isn't any way to make the website data store non-persistent for th
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
MacOSPlatform(available: "12.0")
MacOSPlatform(available: "12.0"),
WindowsPlatform(
available: '1.0.774.44',
apiName: 'ICoreWebView2Controller2.put_DefaultBackgroundColor',
apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller2?view=webview2-1.0.2210.55#put_defaultbackgroundcolor'
)
])
bool? transparentBackground;
@ -323,7 +337,13 @@ because there isn't any way to make the website data store non-persistent for th
///Set to `true` to disable context menu. The default value is `false`.
@SupportedPlatforms(
platforms: [AndroidPlatform(), IOSPlatform(), WebPlatform()])
platforms: [AndroidPlatform(), IOSPlatform(), WebPlatform(),
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_AreDefaultContextMenusEnabled",
apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredefaultcontextmenusenabled"
)
])
bool? disableContextMenu;
///Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
@ -333,7 +353,12 @@ because there isn't any way to make the website data store non-persistent for th
apiUrl:
"https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setSupportZoom(boolean)"),
IOSPlatform(),
MacOSPlatform()
MacOSPlatform(),
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_IsZoomControlEnabled",
apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_iszoomcontrolenabled"
)
])
bool? supportZoom;
@ -1537,7 +1562,12 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri
available: "13.3",
apiName: "WKWebView.isInspectable",
apiUrl:
"https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable")
"https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable"),
WindowsPlatform(
apiName: "ICoreWebView2Settings.put_AreDevToolsEnabled",
apiUrl:
"https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredevtoolsenabled"
)
])
bool? isInspectable;

View File

@ -371,6 +371,7 @@ class InAppWebViewSettings {
///- Android native WebView
///- iOS
///- Web but iframe requires same origin
///- Windows ([Official API - ICoreWebView2Settings.put_AreDefaultContextMenusEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredefaultcontextmenusenabled))
bool? disableContextMenu;
///Sets whether the default Android WebViews internal error page should be suppressed or displayed for bad navigations.
@ -648,6 +649,7 @@ class InAppWebViewSettings {
///**Officially Supported Platforms/Implementations**:
///- iOS 16.4+ ([Official API - WKWebView.isInspectable](https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable))
///- MacOS 13.3+ ([Official API - WKWebView.isInspectable](https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable))
///- Windows ([Official API - ICoreWebView2Settings.put_AreDevToolsEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredevtoolsenabled))
bool? isInspectable;
///A Boolean value that determines whether paging is enabled for the scroll view.
@ -691,6 +693,7 @@ class InAppWebViewSettings {
///- iOS ([Official API - WKWebpagePreferences.allowsContentJavaScript](https://developer.apple.com/documentation/webkit/wkwebpagepreferences/3552422-allowscontentjavascript/))
///- MacOS ([Official API - WKWebpagePreferences.allowsContentJavaScript](https://developer.apple.com/documentation/webkit/wkwebpagepreferences/3552422-allowscontentjavascript/))
///- Web
///- Windows ([Official API - ICoreWebView2Settings.put_IsScriptEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_isscriptenabled))
bool? javaScriptEnabled;
///Sets the underlying layout algorithm. This will cause a re-layout of the WebView.
@ -983,6 +986,7 @@ class InAppWebViewSettings {
///- Android native WebView ([Official API - WebSettings.setSupportZoom](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setSupportZoom(boolean)))
///- iOS
///- MacOS
///- Windows ([Official API - ICoreWebView2Settings.put_IsZoomControlEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_iszoomcontrolenabled))
bool? supportZoom;
///Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory. The default value is `false`.
@ -1012,6 +1016,7 @@ class InAppWebViewSettings {
///- Android native WebView
///- iOS
///- MacOS 12.0+
///- Windows 1.0.774.44+ ([Official API - ICoreWebView2Controller2.put_DefaultBackgroundColor](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller2?view=webview2-1.0.2210.55#put_defaultbackgroundcolor))
bool? transparentBackground;
///The color the web view displays behind the active page, visible when the user scrolls beyond the bounds of the page.
@ -1137,6 +1142,7 @@ class InAppWebViewSettings {
///- Android native WebView
///- iOS
///- MacOS
///- Windows
bool? useShouldOverrideUrlLoading;
///Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport.
@ -1154,6 +1160,7 @@ class InAppWebViewSettings {
///- Android native WebView ([Official API - WebSettings.setUserAgentString](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setUserAgentString(java.lang.String)))
///- iOS ([Official API - WKWebView.customUserAgent](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent))
///- MacOS ([Official API - WKWebView.customUserAgent](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent))
///- Windows ([Official API - ICoreWebView2Settings2.put_UserAgent](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings2?view=webview2-1.0.2210.55#put_useragent))
String? userAgent;
///Define whether the vertical scrollbar should be drawn or not. The default value is `true`.

View File

@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import '../inappwebview_platform.dart';
import '../types/disposable.dart';
import '../webview_environment/platform_webview_environment.dart';
import 'platform_inappwebview_controller.dart';
import 'platform_webview.dart';
@ -17,6 +18,7 @@ class PlatformHeadlessInAppWebViewCreationParams
/// Used by the platform implementation to create a new [PlatformHeadlessInAppWebView].
const PlatformHeadlessInAppWebViewCreationParams(
{this.initialSize = const Size(-1, -1),
this.webViewEnvironment,
super.controllerFromPlatform,
super.windowId,
super.onWebViewCreated,
@ -141,6 +143,12 @@ class PlatformHeadlessInAppWebViewCreationParams
///- Web
///- MacOS
final Size initialSize;
///Used to create the [PlatformHeadlessInAppWebView] using the specified environment.
///
///**Officially Supported Platforms/Implementations**:
///- Windows
final PlatformWebViewEnvironment? webViewEnvironment;
}
///{@template flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebView}

View File

@ -134,6 +134,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url))
///- MacOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url))
///- Web
///- Windows ([Official API - ICoreWebView2.get_Source](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_source))
///{@endtemplate}
Future<WebUri?> getUrl() {
throw UnimplementedError(
@ -150,6 +151,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title))
///- MacOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title))
///- Web
///- Windows ([Official API - ICoreWebView2.get_DocumentTitle](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_documenttitle))
///{@endtemplate}
Future<String?> getTitle() {
throw UnimplementedError(
@ -224,6 +226,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl))
///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl))
///- Web
///- Windows ([Official API - ICoreWebView2_2.NavigateWithWebResourceRequest](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_2?view=webview2-1.0.2210.55#navigatewithwebresourcerequest))
///{@endtemplate}
Future<void> loadUrl(
{required URLRequest urlRequest,
@ -271,11 +274,14 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///Specify a directory to give WebView permission to read additional files in the specified directory.
///**NOTE**: available only on iOS and MacOS.
///
///**NOTE for Windows**: only the [data] parameter is used.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.loadDataWithBaseURL](https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)))
///- iOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load))
///- MacOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load))
///- Web
///- Windows ([Official API - ICoreWebView2.NavigateToString](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#navigatetostring))
///{@endtemplate}
Future<void> loadData(
{required String data,
@ -327,6 +333,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load))
///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load))
///- Web
///- Windows ([Official API - ICoreWebView2.Navigate](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#navigate))
///{@endtemplate}
Future<void> loadFile({required String assetFilePath}) {
throw UnimplementedError(
@ -343,6 +350,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload))
///- MacOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload))
///- Web ([Official API - Location.reload](https://developer.mozilla.org/en-US/docs/Web/API/Location/reload))
///- Windows ([Official API - ICoreWebView2.Reload](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#reload))
///{@endtemplate}
Future<void> reload() {
throw UnimplementedError(
@ -359,6 +367,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback))
///- MacOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback))
///- Web ([Official API - History.back](https://developer.mozilla.org/en-US/docs/Web/API/History/back))
///- Windows ([Official API - ICoreWebView2.GoBack](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#goback))
///{@endtemplate}
Future<void> goBack() {
throw UnimplementedError(
@ -372,6 +381,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView ([Official API - WebView.canGoBack](https://developer.android.com/reference/android/webkit/WebView#canGoBack()))
///- iOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback))
///- MacOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback))
///- Windows ([Official API - ICoreWebView2.get_CanGoBack](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_cangoback))
///{@endtemplate}
Future<bool> canGoBack() {
throw UnimplementedError(
@ -388,6 +398,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward))
///- MacOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward))
///- Web ([Official API - History.forward](https://developer.mozilla.org/en-US/docs/Web/API/History/forward))
///- Windows ([Official API - ICoreWebView2.GoForward](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#goforward))
///{@endtemplate}
Future<void> goForward() {
throw UnimplementedError(
@ -401,6 +412,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView ([Official API - WebView.canGoForward](https://developer.android.com/reference/android/webkit/WebView#canGoForward()))
///- iOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward))
///- MacOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward))
///- Windows ([Official API - ICoreWebView2.get_CanGoForward](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_cangoforward))
///{@endtemplate}
Future<bool> canGoForward() {
throw UnimplementedError(
@ -417,6 +429,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go))
///- MacOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go))
///- Web ([Official API - History.go](https://developer.mozilla.org/en-US/docs/Web/API/History/go))
///- Windows
///{@endtemplate}
Future<void> goBackOrForward({required int steps}) {
throw UnimplementedError(
@ -430,6 +443,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView ([Official API - WebView.canGoBackOrForward](https://developer.android.com/reference/android/webkit/WebView#canGoBackOrForward(int)))
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<bool> canGoBackOrForward({required int steps}) {
throw UnimplementedError(
@ -446,6 +460,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
Future<void> goTo({required WebHistoryItem historyItem}) {
throw UnimplementedError('goTo is not implemented on the current platform');
@ -459,6 +474,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
Future<bool> isLoading() {
throw UnimplementedError(
@ -475,6 +491,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading))
///- MacOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading))
///- Web ([Official API - Window.stop](https://developer.mozilla.org/en-US/docs/Web/API/Window/stop))
///- Windows ([Official API - ICoreWebView2.Stop](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#stop))
///{@endtemplate}
Future<void> stopLoading() {
throw UnimplementedError(
@ -490,7 +507,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///Those changes remain visible to all scripts, regardless of which content world you specify.
///For more information about content worlds, see [ContentWorld].
///Available on iOS 14.0+ and MacOS 11.0+.
///**NOTE**: not used on Web.
///**NOTE**: not used on Web and on Windows platforms.
///
///**NOTE**: This method shouldn't be called in the [PlatformWebViewCreationParams.onWebViewCreated] or [PlatformWebViewCreationParams.onLoadStart] events,
///because, in these events, the `WebView` is not ready to handle it yet.
@ -504,6 +521,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript))
///- MacOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript))
///- Web ([Official API - Window.eval](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval?retiredLocale=it))
///- Windows
///{@endtemplate}
Future<dynamic> evaluateJavascript(
{required String source, ContentWorld? contentWorld}) {
@ -551,6 +569,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
Future<dynamic> injectJavascriptFileFromAsset(
{required String assetFilePath}) {
@ -731,6 +750,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot))
///- MacOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot))
///- Windows
///{@endtemplate}
Future<Uint8List?> takeScreenshot(
{ScreenshotConfiguration? screenshotConfiguration}) {
@ -776,6 +796,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView ([Official API - WebView.copyBackForwardList](https://developer.android.com/reference/android/webkit/WebView#copyBackForwardList()))
///- iOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist))
///- MacOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist))
///- Windows
///{@endtemplate}
Future<WebHistory?> getCopyBackForwardList() {
throw UnimplementedError(
@ -1173,6 +1194,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript))
///- MacOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript))
///- Windows
///{@endtemplate}
Future<void> addUserScript({required UserScript userScript}) {
throw UnimplementedError(
@ -1190,6 +1212,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> addUserScripts({required List<UserScript> userScripts}) {
throw UnimplementedError(
@ -1209,6 +1232,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<bool> removeUserScript({required UserScript userScript}) {
throw UnimplementedError(
@ -1227,6 +1251,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> removeUserScriptsByGroupName({required String groupName}) {
throw UnimplementedError(
@ -1245,6 +1270,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
Future<void> removeUserScripts({required List<UserScript> userScripts}) {
throw UnimplementedError(
@ -1262,6 +1288,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts))
///- MacOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts))
///- Windows
///{@endtemplate}
Future<void> removeAllUserScripts() {
throw UnimplementedError(
@ -1275,6 +1302,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
bool hasUserScript({required UserScript userScript}) {
throw UnimplementedError(
@ -1315,6 +1343,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
///- Android native WebView
///- iOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript))
///- MacOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript))
///- Windows
///{@endtemplate}
Future<CallAsyncJavaScriptResult?> callAsyncJavaScript(
{required String functionBody,
@ -2011,6 +2040,62 @@ abstract class PlatformInAppWebViewController extends PlatformInterface
'loadSimulatedRequest is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.openDevTools}
///Opens the DevTools window for the current document in the WebView.
///Does nothing if run when the DevTools window is already open.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2.OpenDevToolsWindow](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#opendevtoolswindow))
///{@endtemplate}
Future<void> openDevTools() {
throw UnimplementedError(
'openDevTools is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.callDevToolsProtocolMethod}
///Runs an asynchronous `DevToolsProtocol` method.
///
///For more information about available methods, navigate to [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot).
///The [methodName] parameter is the full name of the method in the `{domain}.{method}` format.
///The [parameters] will be a JSON formatted string containing the parameters for the corresponding method.
///This function throws an error if the [methodName] is unknown or the [parameters] has an error.
///In the case of such an error, the [parameters] parameter of the
///handler will include information about the error.
///Note even though WebView dispatches the CDP messages in the order called,
///CDP method calls may be processed out of order.
///If you require CDP methods to run in a particular order, you should wait for
///the previous method's completed handler to run before calling the next method.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2.CallDevToolsProtocolMethod](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#calldevtoolsprotocolmethod))
///{@endtemplate}
Future<dynamic> callDevToolsProtocolMethod({required String methodName, Map<String, dynamic>? parameters}) {
throw UnimplementedError(
'callDevToolsProtocolMethod is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addDevToolsProtocolEventListener}
///Subscribe to a `DevToolsProtocol` event.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2DevToolsProtocolEventReceiver.add_DevToolsProtocolEventReceived](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#add_devtoolsprotocoleventreceived))
///{@endtemplate}
Future<void> addDevToolsProtocolEventListener({required String eventName, required Function(dynamic data) callback}) {
throw UnimplementedError(
'addDevToolsProtocolEventListener is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeDevToolsProtocolEventListener}
///Remove an event handler previously added with [addDevToolsProtocolEventListener].
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2DevToolsProtocolEventReceiver.remove_DevToolsProtocolEventReceived](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#remove_devtoolsprotocoleventreceived))
///{@endtemplate}
Future<void> removeDevToolsProtocolEventListener({required String eventName}) {
throw UnimplementedError(
'removeDevToolsProtocolEventListener is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getIFrameId}
///Returns the iframe `id` attribute used on the Web platform.
///

View File

@ -5,6 +5,7 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import '../inappwebview_platform.dart';
import '../types/disposable.dart';
import '../webview_environment/platform_webview_environment.dart';
import 'in_app_webview_keep_alive.dart';
import 'platform_webview.dart';
import 'platform_headless_in_app_webview.dart';
@ -24,6 +25,7 @@ class PlatformInAppWebViewWidgetCreationParams
this.headlessWebView,
this.keepAlive,
this.preventGestureDelay,
this.webViewEnvironment,
super.controllerFromPlatform,
super.windowId,
super.onWebViewCreated,
@ -181,6 +183,12 @@ class PlatformInAppWebViewWidgetCreationParams
///**Officially Supported Platforms/Implementations**:
///- iOS
final bool? preventGestureDelay;
///Used to create the [PlatformInAppWebViewWidget] using the specified environment.
///
///**Officially Supported Platforms/Implementations**:
///- Windows
final PlatformWebViewEnvironment? webViewEnvironment;
}
/// Interface for a platform implementation of a web view widget.
@ -192,6 +200,7 @@ class PlatformInAppWebViewWidgetCreationParams
///- Android native WebView
///- iOS
///- Web
///- Windows
///{@endtemplate}
abstract class PlatformInAppWebViewWidget extends PlatformInterface
implements Disposable {

View File

@ -38,6 +38,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
final void Function(T controller)? onWebViewCreated;
@ -54,6 +55,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- Web
///- Windows ([Official API - ICoreWebView2.add_NavigationStarting](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationstarting))
///{@endtemplate}
final void Function(T controller, WebUri? url)? onLoadStart;
@ -68,6 +70,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- Web ([Official API - Window.onload](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event))
///- Windows ([Official API - ICoreWebView2.add_NavigationCompleted](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted))
///{@endtemplate}
final void Function(T controller, WebUri? url)? onLoadStop;
@ -83,6 +86,7 @@ class PlatformWebViewCreationParams<T> {
///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
///- Windows ([Official API - ICoreWebView2.add_NavigationCompleted](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted))
///{@endtemplate}
final void Function(
T controller, WebResourceRequest request, WebResourceError error)?
@ -107,6 +111,7 @@ class PlatformWebViewCreationParams<T> {
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- Windows ([Official API - ICoreWebView2.add_NavigationCompleted](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted))
///{@endtemplate}
final void Function(T controller, WebResourceRequest request,
WebResourceResponse errorResponse)? onReceivedHttpError;
@ -499,6 +504,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS
///- MacOS
///- Web
///- Windows ([Official API - ICoreWebView2.add_HistoryChanged](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_historychanged))
///{@endtemplate}
final void Function(T controller, WebUri? url, bool? isReload)?
onUpdateVisitedHistory;
@ -593,6 +599,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS
///- MacOS
///- Web
///- Windows ([Official API - ICoreWebView2.add_DocumentTitleChanged](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_documenttitlechanged))
///{@endtemplate}
final void Function(T controller, String? title)? onTitleChanged;
@ -1052,6 +1059,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
final URLRequest? initialUrlRequest;
@ -1063,6 +1071,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
final String? initialFile;
@ -1074,6 +1083,7 @@ class PlatformWebViewCreationParams<T> {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
final InAppWebViewInitialData? initialData;
@ -1114,6 +1124,7 @@ class PlatformWebViewCreationParams<T> {
///- Android native WebView
///- iOS
///- MacOS
///- Windows
///{@endtemplate}
final UnmodifiableListView<UserScript>? initialUserScripts;

View File

@ -24,6 +24,7 @@ import 'platform_tracing_controller.dart';
import 'platform_webview_asset_loader.dart';
import 'platform_webview_feature.dart';
import 'in_app_localhost_server.dart';
import 'webview_environment/platform_webview_environment.dart';
/// Interface for a platform implementation of a WebView.
abstract class InAppWebViewPlatform extends PlatformInterface {
@ -430,4 +431,24 @@ abstract class InAppWebViewPlatform extends PlatformInterface {
throw UnimplementedError(
'createPlatformChromeSafariBrowserStatic is not implemented on the current platform.');
}
/// Creates a new [PlatformWebViewEnvironment].
///
/// This function should only be called by the app-facing package.
/// Look at using [WebViewEnvironment] in `flutter_inappwebview` instead.
PlatformWebViewEnvironment createPlatformWebViewEnvironment(
PlatformWebViewEnvironmentCreationParams params,
) {
throw UnimplementedError(
'createPlatformWebViewEnvironment is not implemented on the current platform.');
}
/// Creates a new empty [PlatformWebViewEnvironment] to access static methods.
///
/// This function should only be called by the app-facing package.
/// Look at using [WebViewEnvironment] in `flutter_inappwebview` instead.
PlatformWebViewEnvironment createPlatformWebViewEnvironmentStatic() {
throw UnimplementedError(
'createPlatformWebViewEnvironmentStatic is not implemented on the current platform.');
}
}

View File

@ -1,5 +1,6 @@
export 'inappwebview_platform.dart';
export 'types/main.dart';
export 'webview_environment/main.dart';
export 'in_app_webview/main.dart';
export 'in_app_browser/main.dart';
export 'chrome_safari_browser/main.dart';

View File

@ -8,6 +8,7 @@ import 'types/main.dart';
import 'web_uri.dart';
import 'inappwebview_platform.dart';
import 'in_app_webview/platform_headless_in_app_webview.dart';
import 'webview_environment/platform_webview_environment.dart';
/// Object specifying creation parameters for creating a [PlatformCookieManager].
///
@ -16,7 +17,13 @@ import 'in_app_webview/platform_headless_in_app_webview.dart';
@immutable
class PlatformCookieManagerCreationParams {
/// Used by the platform implementation to create a new [PlatformCookieManager].
const PlatformCookieManagerCreationParams();
const PlatformCookieManagerCreationParams({this.webViewEnvironment});
///Used to create the [PlatformCookieManager] using the specified environment.
///
///**Officially Supported Platforms/Implementations**:
///- Windows
final PlatformWebViewEnvironment? webViewEnvironment;
}
///{@template flutter_inappwebview_platform_interface.PlatformCookieManager}
@ -33,6 +40,7 @@ class PlatformCookieManagerCreationParams {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
abstract class PlatformCookieManager extends PlatformInterface {
/// Creates a new [PlatformCookieManager]
@ -87,6 +95,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
///- iOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
///- Web
///- Windows
///{@endtemplate}
Future<bool> setCookie(
{required WebUri url,
@ -126,6 +135,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
///- Web
///- Windows
///{@endtemplate}
Future<List<Cookie>> getCookies(
{required WebUri url,
@ -156,6 +166,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
Future<Cookie?> getCookie(
{required WebUri url,
@ -191,6 +202,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
///- iOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
///- Web
///- Windows
///{@endtemplate}
Future<bool> deleteCookie(
{required WebUri url,
@ -228,6 +240,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
Future<bool> deleteCookies(
{required WebUri url,
@ -254,6 +267,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
///- Android native WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)))
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
///- Windows
///{@endtemplate}
Future<bool> deleteAllCookies() {
throw UnimplementedError(

View File

@ -11,36 +11,48 @@ class CompressFormat_ {
///Compress to the `PNG` format.
///PNG is lossless, so `quality` is ignored.
@EnumSupportedPlatforms(platforms: [
EnumAndroidPlatform(),
EnumIOSPlatform(),
EnumMacOSPlatform(),
EnumWindowsPlatform(),
])
static const PNG = const CompressFormat_._internal("PNG");
///Compress to the `JPEG` format.
///Quality of `0` means compress for the smallest size.
///`100` means compress for max visual quality.
@EnumSupportedPlatforms(platforms: [
EnumAndroidPlatform(),
EnumIOSPlatform(),
EnumMacOSPlatform(),
EnumWindowsPlatform(),
])
static const JPEG = const CompressFormat_._internal("JPEG");
///Compress to the `WEBP` lossy format.
///Quality of `0` means compress for the smallest size.
///`100` means compress for max visual quality.
///
///**NOTE**: available only on Android.
@EnumSupportedPlatforms(platforms: [
EnumAndroidPlatform(),
EnumWindowsPlatform(),
])
static const WEBP = const CompressFormat_._internal("WEBP");
///Compress to the `WEBP` lossy format.
///Quality of `0` means compress for the smallest size.
///`100` means compress for max visual quality.
///
///**NOTE**: available only on Android.
///
///**NOTE for Android**: available on Android 30+.
@EnumSupportedPlatforms(platforms: [
EnumAndroidPlatform(available: '30'),
])
static const WEBP_LOSSY = const CompressFormat_._internal("WEBP_LOSSY");
///Compress to the `WEBP` lossless format.
///Quality refers to how much effort to put into compression.
///A value of `0` means to compress quickly, resulting in a relatively large file size.
///`100` means to spend more time compressing, resulting in a smaller file.
///
///**NOTE**: available only on Android.
///
///**NOTE for Android**: available on Android 30+.
@EnumSupportedPlatforms(platforms: [
EnumAndroidPlatform(available: '30'),
])
static const WEBP_LOSSLESS = const CompressFormat_._internal("WEBP_LOSSLESS");
}

View File

@ -19,17 +19,31 @@ class CompressFormat {
///Compress to the `JPEG` format.
///Quality of `0` means compress for the smallest size.
///`100` means compress for max visual quality.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Windows
static const JPEG = CompressFormat._internal('JPEG', 'JPEG');
///Compress to the `PNG` format.
///PNG is lossless, so `quality` is ignored.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Windows
static const PNG = CompressFormat._internal('PNG', 'PNG');
///Compress to the `WEBP` lossy format.
///Quality of `0` means compress for the smallest size.
///`100` means compress for max visual quality.
///
///**NOTE**: available only on Android.
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- Windows
static const WEBP = CompressFormat._internal('WEBP', 'WEBP');
///Compress to the `WEBP` lossless format.
@ -37,9 +51,8 @@ class CompressFormat {
///A value of `0` means to compress quickly, resulting in a relatively large file size.
///`100` means to spend more time compressing, resulting in a smaller file.
///
///**NOTE**: available only on Android.
///
///**NOTE for Android**: available on Android 30+.
///**Officially Supported Platforms/Implementations**:
///- Android native WebView 30+
static const WEBP_LOSSLESS =
CompressFormat._internal('WEBP_LOSSLESS', 'WEBP_LOSSLESS');
@ -47,9 +60,8 @@ class CompressFormat {
///Quality of `0` means compress for the smallest size.
///`100` means compress for max visual quality.
///
///**NOTE**: available only on Android.
///
///**NOTE for Android**: available on Android 30+.
///**Officially Supported Platforms/Implementations**:
///- Android native WebView 30+
static const WEBP_LOSSY =
CompressFormat._internal('WEBP_LOSSY', 'WEBP_LOSSY');

View File

@ -14,7 +14,8 @@ class Cookie_ {
IOSPlatform(),
MacOSPlatform(),
AndroidPlatform(),
WebPlatform()
WebPlatform(),
WindowsPlatform()
])
String name;
@ -23,7 +24,8 @@ class Cookie_ {
IOSPlatform(),
MacOSPlatform(),
AndroidPlatform(),
WebPlatform()
WebPlatform(),
WindowsPlatform()
])
dynamic value;
@ -33,12 +35,17 @@ class Cookie_ {
MacOSPlatform(),
AndroidPlatform(
note:
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
WindowsPlatform()
])
int? expiresDate;
///Indicates if the cookie is a session only cookie.
@SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()])
@SupportedPlatforms(platforms: [
IOSPlatform(),
MacOSPlatform(),
WindowsPlatform()
])
bool? isSessionOnly;
///The cookie domain.
@ -47,7 +54,8 @@ class Cookie_ {
MacOSPlatform(),
AndroidPlatform(
note:
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
WindowsPlatform()
])
String? domain;
@ -57,7 +65,8 @@ class Cookie_ {
MacOSPlatform(),
AndroidPlatform(
note:
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
WindowsPlatform()
])
HTTPCookieSameSitePolicy_? sameSite;
@ -67,7 +76,8 @@ class Cookie_ {
MacOSPlatform(),
AndroidPlatform(
note:
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
WindowsPlatform()
])
bool? isSecure;
@ -77,7 +87,8 @@ class Cookie_ {
MacOSPlatform(),
AndroidPlatform(
note:
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
WindowsPlatform()
])
bool? isHttpOnly;
@ -87,7 +98,8 @@ class Cookie_ {
MacOSPlatform(),
AndroidPlatform(
note:
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
WindowsPlatform()
])
String? path;

View File

@ -16,6 +16,7 @@ class Cookie {
///- iOS
///- MacOS
///- Android native WebView
///- Windows
String? domain;
///The cookie expiration date in milliseconds.
@ -26,6 +27,7 @@ class Cookie {
///- iOS
///- MacOS
///- Android native WebView
///- Windows
int? expiresDate;
///Indicates if the cookie is a http only cookie.
@ -36,6 +38,7 @@ class Cookie {
///- iOS
///- MacOS
///- Android native WebView
///- Windows
bool? isHttpOnly;
///Indicates if the cookie is secure or not.
@ -46,6 +49,7 @@ class Cookie {
///- iOS
///- MacOS
///- Android native WebView
///- Windows
bool? isSecure;
///Indicates if the cookie is a session only cookie.
@ -53,6 +57,7 @@ class Cookie {
///**Officially Supported Platforms/Implementations**:
///- iOS
///- MacOS
///- Windows
bool? isSessionOnly;
///The cookie name.
@ -62,6 +67,7 @@ class Cookie {
///- MacOS
///- Android native WebView
///- Web but iframe requires same origin
///- Windows
String name;
///The cookie path.
@ -72,6 +78,7 @@ class Cookie {
///- iOS
///- MacOS
///- Android native WebView
///- Windows
String? path;
///The cookie same site policy.
@ -82,6 +89,7 @@ class Cookie {
///- iOS
///- MacOS
///- Android native WebView
///- Windows
HTTPCookieSameSitePolicy? sameSite;
///The cookie value.
@ -91,6 +99,7 @@ class Cookie {
///- MacOS
///- Android native WebView
///- Web but iframe requires same origin
///- Windows
dynamic value;
Cookie(
{this.domain,

View File

@ -54,7 +54,8 @@ class NavigationAction_ {
available: "21",
apiName: "WebResourceRequest.isRedirect",
apiUrl:
"https://developer.android.com/reference/android/webkit/WebResourceRequest#isRedirect()")
"https://developer.android.com/reference/android/webkit/WebResourceRequest#isRedirect()"),
WindowsPlatform()
])
bool? isRedirect;
@ -62,7 +63,7 @@ class NavigationAction_ {
@Deprecated("Use navigationType instead")
IOSWKNavigationType_? iosWKNavigationType;
///The type of action triggering the navigation.ì
///The type of action triggering the navigation.
@SupportedPlatforms(platforms: [
IOSPlatform(
apiName: "WKNavigationAction.navigationType",
@ -71,7 +72,8 @@ class NavigationAction_ {
MacOSPlatform(
apiName: "WKNavigationAction.navigationType",
apiUrl:
"https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype")
"https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype"),
WindowsPlatform()
])
NavigationType_? navigationType;

View File

@ -52,13 +52,15 @@ class NavigationAction {
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView 21+ ([Official API - WebResourceRequest.isRedirect](https://developer.android.com/reference/android/webkit/WebResourceRequest#isRedirect()))
///- Windows
bool? isRedirect;
///The type of action triggering the navigation.ì
///The type of action triggering the navigation.
///
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationAction.navigationType](https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype))
///- MacOS ([Official API - WKNavigationAction.navigationType](https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype))
///- Windows
NavigationType? navigationType;
///The URL request object associated with the navigation action.

View File

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../in_app_webview/platform_webview.dart';
part 'navigation_type.g.dart';
@ -6,26 +7,119 @@ part 'navigation_type.g.dart';
@ExchangeableEnum()
class NavigationType_ {
// ignore: unused_field
final int _value;
final String _value;
// ignore: unused_field
final int? _nativeValue = null;
const NavigationType_._internal(this._value);
///A link with an href attribute was activated by the user.
static const LINK_ACTIVATED = const NavigationType_._internal(0);
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'WKNavigationType.linkActivated',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated',
value: 0),
EnumMacOSPlatform(
apiName: 'WKNavigationType.linkActivated',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated',
value: 0),
EnumWindowsPlatform(
value: 0
),
])
static const LINK_ACTIVATED = const NavigationType_._internal('LINK_ACTIVATED');
///A form was submitted.
static const FORM_SUBMITTED = const NavigationType_._internal(1);
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'WKNavigationType.formSubmitted',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted',
value: 1),
EnumMacOSPlatform(
apiName: 'WKNavigationType.formSubmitted',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted',
value: 1),
])
static const FORM_SUBMITTED = const NavigationType_._internal('FORM_SUBMITTED');
///An item from the back-forward list was requested.
static const BACK_FORWARD = const NavigationType_._internal(2);
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'WKNavigationType.formSubmitted',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted',
value: 2),
EnumMacOSPlatform(
apiName: 'WKNavigationType.formSubmitted',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted',
value: 2),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind',
value: 1
),
])
static const BACK_FORWARD = const NavigationType_._internal('BACK_FORWARD');
///The webpage was reloaded.
static const RELOAD = const NavigationType_._internal(3);
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'WKNavigationType.reload',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/reload',
value: 3),
EnumMacOSPlatform(
apiName: 'WKNavigationType.reload',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/reload',
value: 3),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_NAVIGATION_KIND_RELOAD',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind',
value: 2
),
])
static const RELOAD = const NavigationType_._internal('RELOAD');
///A form was resubmitted (for example by going back, going forward, or reloading).
static const FORM_RESUBMITTED = const NavigationType_._internal(4);
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'WKNavigationType.formSubmitted',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted',
value: 4),
EnumMacOSPlatform(
apiName: 'WKNavigationType.formSubmitted',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted',
value: 4),
])
static const FORM_RESUBMITTED = const NavigationType_._internal('FORM_RESUBMITTED');
///Navigation is taking place for some other reason.
static const OTHER = const NavigationType_._internal(-1);
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'WKNavigationType.other',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/other',
value: -1),
EnumMacOSPlatform(
apiName: 'WKNavigationType.other',
apiUrl:
'https://developer.apple.com/documentation/webkit/wknavigationtype/other',
value: -1),
EnumWindowsPlatform(
value: 3
),
])
static const OTHER = const NavigationType_._internal('OTHER');
}
///Class that represents the type of action triggering a navigation on iOS for the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event.

View File

@ -8,31 +8,131 @@ part of 'navigation_type.dart';
///Class that represents the type of action triggering a navigation for the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event.
class NavigationType {
final int _value;
final int _nativeValue;
final String _value;
final int? _nativeValue;
const NavigationType._internal(this._value, this._nativeValue);
// ignore: unused_element
factory NavigationType._internalMultiPlatform(
int value, Function nativeValue) =>
String value, Function nativeValue) =>
NavigationType._internal(value, nativeValue());
///An item from the back-forward list was requested.
static const BACK_FORWARD = NavigationType._internal(2, 2);
///
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted))
///- MacOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted))
///- Windows ([Official API - COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind))
static final BACK_FORWARD =
NavigationType._internalMultiPlatform('BACK_FORWARD', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 2;
case TargetPlatform.macOS:
return 2;
case TargetPlatform.windows:
return 1;
default:
break;
}
return null;
});
///A form was resubmitted (for example by going back, going forward, or reloading).
static const FORM_RESUBMITTED = NavigationType._internal(4, 4);
///
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted))
///- MacOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted))
static final FORM_RESUBMITTED =
NavigationType._internalMultiPlatform('FORM_RESUBMITTED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 4;
case TargetPlatform.macOS:
return 4;
default:
break;
}
return null;
});
///A form was submitted.
static const FORM_SUBMITTED = NavigationType._internal(1, 1);
///
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted))
///- MacOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted))
static final FORM_SUBMITTED =
NavigationType._internalMultiPlatform('FORM_SUBMITTED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 1;
case TargetPlatform.macOS:
return 1;
default:
break;
}
return null;
});
///A link with an href attribute was activated by the user.
static const LINK_ACTIVATED = NavigationType._internal(0, 0);
///
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationType.linkActivated](https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated))
///- MacOS ([Official API - WKNavigationType.linkActivated](https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated))
///- Windows
static final LINK_ACTIVATED =
NavigationType._internalMultiPlatform('LINK_ACTIVATED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 0;
case TargetPlatform.macOS:
return 0;
case TargetPlatform.windows:
return 0;
default:
break;
}
return null;
});
///Navigation is taking place for some other reason.
static const OTHER = NavigationType._internal(-1, -1);
///
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationType.other](https://developer.apple.com/documentation/webkit/wknavigationtype/other))
///- MacOS ([Official API - WKNavigationType.other](https://developer.apple.com/documentation/webkit/wknavigationtype/other))
///- Windows
static final OTHER = NavigationType._internalMultiPlatform('OTHER', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1;
case TargetPlatform.macOS:
return -1;
case TargetPlatform.windows:
return 3;
default:
break;
}
return null;
});
///The webpage was reloaded.
static const RELOAD = NavigationType._internal(3, 3);
///
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationType.reload](https://developer.apple.com/documentation/webkit/wknavigationtype/reload))
///- MacOS ([Official API - WKNavigationType.reload](https://developer.apple.com/documentation/webkit/wknavigationtype/reload))
///- Windows ([Official API - COREWEBVIEW2_NAVIGATION_KIND_RELOAD](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind))
static final RELOAD = NavigationType._internalMultiPlatform('RELOAD', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 3;
case TargetPlatform.macOS:
return 3;
case TargetPlatform.windows:
return 2;
default:
break;
}
return null;
});
///Set of all values of [NavigationType].
static final Set<NavigationType> values = [
@ -44,8 +144,8 @@ class NavigationType {
NavigationType.RELOAD,
].toSet();
///Gets a possible [NavigationType] instance from [int] value.
static NavigationType? fromValue(int? value) {
///Gets a possible [NavigationType] instance from [String] value.
static NavigationType? fromValue(String? value) {
if (value != null) {
try {
return NavigationType.values
@ -70,11 +170,11 @@ class NavigationType {
return null;
}
///Gets [int] value.
int toValue() => _value;
///Gets [String] value.
String toValue() => _value;
///Gets [int] native value.
int toNativeValue() => _nativeValue;
///Gets [int?] native value.
int? toNativeValue() => _nativeValue;
@override
int get hashCode => _value.hashCode;
@ -84,21 +184,7 @@ class NavigationType {
@override
String toString() {
switch (_value) {
case 2:
return 'BACK_FORWARD';
case 4:
return 'FORM_RESUBMITTED';
case 1:
return 'FORM_SUBMITTED';
case 0:
return 'LINK_ACTIVATED';
case -1:
return 'OTHER';
case 3:
return 'RELOAD';
}
return _value.toString();
return _value;
}
}

View File

@ -12,6 +12,12 @@ class ScreenshotConfiguration_ {
///The portion of your web view to capture, specified as a rectangle in the views coordinate system.
///The default value of this property is `null`, which captures everything in the views bounds rectangle.
///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object.
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
MacOSPlatform(),
WindowsPlatform()
])
InAppWebViewRect_? rect;
///The width of the captured image, in points.
@ -19,14 +25,31 @@ class ScreenshotConfiguration_ {
///The web view maintains the aspect ratio of the captured content, but scales it to match the width you specify.
///
///The default value of this property is `null`, which returns an image whose size matches the original size of the captured rectangle.
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
MacOSPlatform()
])
double? snapshotWidth;
///The compression format of the captured image.
///The default value is [CompressFormat.PNG].
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
MacOSPlatform(),
WindowsPlatform()
])
CompressFormat_ compressFormat;
///Hint to the compressor, `0-100`. The value is interpreted differently depending on the [CompressFormat].
///[CompressFormat.PNG] is lossless, so this value is ignored.
@SupportedPlatforms(platforms: [
AndroidPlatform(),
IOSPlatform(),
MacOSPlatform(),
WindowsPlatform()
])
int quality;
///Use [afterScreenUpdates] instead.
@ -36,10 +59,10 @@ class ScreenshotConfiguration_ {
///A Boolean value that indicates whether to take the snapshot after incorporating any pending screen updates.
///The default value of this property is `true`, which causes the web view to incorporate any recent changes to the views content and then generate the snapshot.
///If you change the value to `false`, the `WebView` takes the snapshot immediately, and before incorporating any new changes.
///
///**NOTE**: available only on iOS.
///
///**NOTE for iOS**: Available from iOS 13.0+.
@SupportedPlatforms(platforms: [
IOSPlatform(available: '13.0'),
MacOSPlatform(available: '10.15'),
])
bool afterScreenUpdates;
@ExchangeableObjectConstructor()

View File

@ -12,13 +12,19 @@ class ScreenshotConfiguration {
///The default value of this property is `true`, which causes the web view to incorporate any recent changes to the views content and then generate the snapshot.
///If you change the value to `false`, the `WebView` takes the snapshot immediately, and before incorporating any new changes.
///
///**NOTE**: available only on iOS.
///
///**NOTE for iOS**: Available from iOS 13.0+.
///**Officially Supported Platforms/Implementations**:
///- iOS 13.0+
///- MacOS 10.15+
bool afterScreenUpdates;
///The compression format of the captured image.
///The default value is [CompressFormat.PNG].
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Windows
CompressFormat compressFormat;
///Use [afterScreenUpdates] instead.
@ -27,11 +33,23 @@ class ScreenshotConfiguration {
///Hint to the compressor, `0-100`. The value is interpreted differently depending on the [CompressFormat].
///[CompressFormat.PNG] is lossless, so this value is ignored.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Windows
int quality;
///The portion of your web view to capture, specified as a rectangle in the views coordinate system.
///The default value of this property is `null`, which captures everything in the views bounds rectangle.
///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Windows
InAppWebViewRect? rect;
///The width of the captured image, in points.
@ -39,6 +57,11 @@ class ScreenshotConfiguration {
///The web view maintains the aspect ratio of the captured content, but scales it to match the width you specify.
///
///The default value of this property is `null`, which returns an image whose size matches the original size of the captured rectangle.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
double? snapshotWidth;
ScreenshotConfiguration(
{this.rect,

View File

@ -24,6 +24,12 @@ class WebHistoryItem_ {
///Position offset respect to the currentIndex of the back-forward [WebHistory.list].
int? offset;
///Unique id of the navigation history entry.
@SupportedPlatforms(platforms: [
WindowsPlatform()
])
int? entryId;
WebHistoryItem_(
{this.originalUrl, this.title, this.url, this.index, this.offset});
{this.originalUrl, this.title, this.url, this.index, this.offset, this.entryId});
}

View File

@ -9,6 +9,12 @@ part of 'web_history_item.dart';
///A convenience class for accessing fields in an entry in the back/forward list of a `WebView`.
///Each [WebHistoryItem] is a snapshot of the requested history item.
class WebHistoryItem {
///Unique id of the navigation history entry.
///
///**Officially Supported Platforms/Implementations**:
///- Windows
int? entryId;
///0-based position index in the back-forward [WebHistory.list].
int? index;
@ -24,7 +30,12 @@ class WebHistoryItem {
///Url of this history item.
WebUri? url;
WebHistoryItem(
{this.index, this.offset, this.originalUrl, this.title, this.url});
{this.entryId,
this.index,
this.offset,
this.originalUrl,
this.title,
this.url});
///Gets a possible [WebHistoryItem] instance from a [Map] value.
static WebHistoryItem? fromMap(Map<String, dynamic>? map) {
@ -32,6 +43,7 @@ class WebHistoryItem {
return null;
}
final instance = WebHistoryItem(
entryId: map['entryId'],
index: map['index'],
offset: map['offset'],
originalUrl:
@ -45,6 +57,7 @@ class WebHistoryItem {
///Converts instance to a map.
Map<String, dynamic> toMap() {
return {
"entryId": entryId,
"index": index,
"offset": offset,
"originalUrl": originalUrl?.toString(),
@ -60,6 +73,6 @@ class WebHistoryItem {
@override
String toString() {
return 'WebHistoryItem{index: $index, offset: $offset, originalUrl: $originalUrl, title: $title, url: $url}';
return 'WebHistoryItem{entryId: $entryId, index: $index, offset: $offset, originalUrl: $originalUrl, title: $title, url: $url}';
}
}

View File

@ -60,7 +60,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.cannotConnectToHost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost',
value: -1004)
value: -1004),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CANNOT_CONNECT',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 12)
])
static const CANNOT_CONNECT_TO_HOST =
WebResourceErrorType_._internal("CANNOT_CONNECT_TO_HOST");
@ -124,7 +129,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.cannotFindHost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost',
value: -1003)
value: -1003),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_HOST_NAME_NOT_RESOLVED',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 13)
])
static const HOST_LOOKUP = WebResourceErrorType_._internal("HOST_LOOKUP");
@ -186,7 +196,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.timedOut',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout',
value: -1001)
value: -1001),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_TIMEOUT',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 7)
])
static const TIMEOUT = WebResourceErrorType_._internal("TIMEOUT");
@ -217,7 +232,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.unknown',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown',
value: -1)
value: -1),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 0)
])
static const UNKNOWN = WebResourceErrorType_._internal("UNKNOWN");
@ -276,7 +296,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.cancelled',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled',
value: -999)
value: -999),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 14)
])
static const CANCELLED = WebResourceErrorType_._internal("CANCELLED");
@ -291,7 +316,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.networkConnectionLost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost',
value: -1005)
value: -1005),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_DISCONNECTED',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 11)
])
static const NETWORK_CONNECTION_LOST =
WebResourceErrorType_._internal("NETWORK_CONNECTION_LOST");
@ -356,7 +386,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.badServerResponse',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse',
value: -1011)
value: -1011),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 8)
])
static const BAD_SERVER_RESPONSE =
WebResourceErrorType_._internal("BAD_SERVER_RESPONSE");
@ -389,7 +424,12 @@ class WebResourceErrorType_ {
apiName: 'URLError.userAuthenticationRequired',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired',
value: -1013)
value: -1013),
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 17),
])
static const USER_AUTHENTICATION_REQUIRED =
WebResourceErrorType_._internal("USER_AUTHENTICATION_REQUIRED");
@ -892,4 +932,64 @@ class WebResourceErrorType_ {
])
static const BACKGROUND_SESSION_WAS_DISCONNECTED =
WebResourceErrorType_._internal("BACKGROUND_SESSION_WAS_DISCONNECTED");
///Indicates that the host is unreachable.
@EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_SERVER_UNREACHABLE',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 6),
])
static const SERVER_UNREACHABLE = WebResourceErrorType_._internal("SERVER_UNREACHABLE");
///Indicates that the connection was stopped.
@EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 9)
])
static const CONNECTION_ABORTED = WebResourceErrorType_._internal("CONNECTION_ABORTED");
///Indicates that the connection was reset.
@EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_RESET',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 10),
])
static const RESET = WebResourceErrorType_._internal("RESET");
///Indicates that the request redirect failed.
@EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_REDIRECT_FAILED',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 15),
])
static const REDIRECT_FAILED = WebResourceErrorType_._internal("REDIRECT_FAILED");
///Indicates that an unexpected error occurred.
@EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_UNEXPECTED_ERROR',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 16),
])
static const UNEXPECTED_ERROR = WebResourceErrorType_._internal("UNEXPECTED_ERROR");
///Indicates that user lacks proper authentication credentials for a proxy server.
@EnumSupportedPlatforms(platforms: [
EnumWindowsPlatform(
apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status',
value: 18),
])
static const VALID_PROXY_AUTHENTICATION_REQUIRED = WebResourceErrorType_._internal("VALID_PROXY_AUTHENTICATION_REQUIRED");
}

View File

@ -97,6 +97,7 @@ class WebResourceErrorType {
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse))
///- MacOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final BAD_SERVER_RESPONSE =
WebResourceErrorType._internalMultiPlatform('BAD_SERVER_RESPONSE', () {
switch (defaultTargetPlatform) {
@ -104,6 +105,8 @@ class WebResourceErrorType {
return -1011;
case TargetPlatform.macOS:
return -1011;
case TargetPlatform.windows:
return 8;
default:
break;
}
@ -154,6 +157,7 @@ class WebResourceErrorType {
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled))
///- MacOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final CANCELLED =
WebResourceErrorType._internalMultiPlatform('CANCELLED', () {
switch (defaultTargetPlatform) {
@ -161,6 +165,8 @@ class WebResourceErrorType {
return -999;
case TargetPlatform.macOS:
return -999;
case TargetPlatform.windows:
return 14;
default:
break;
}
@ -191,6 +197,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_CONNECT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_CONNECT))
///- iOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost))
///- MacOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CANNOT_CONNECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final CANNOT_CONNECT_TO_HOST =
WebResourceErrorType._internalMultiPlatform('CANNOT_CONNECT_TO_HOST', () {
switch (defaultTargetPlatform) {
@ -200,6 +207,8 @@ class WebResourceErrorType {
return -1004;
case TargetPlatform.macOS:
return -1004;
case TargetPlatform.windows:
return 12;
default:
break;
}
@ -408,6 +417,21 @@ class WebResourceErrorType {
return null;
});
///Indicates that the connection was stopped.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final CONNECTION_ABORTED =
WebResourceErrorType._internalMultiPlatform('CONNECTION_ABORTED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.windows:
return 9;
default:
break;
}
return null;
});
///The length of the resource data exceeds the maximum allowed.
///
///**Officially Supported Platforms/Implementations**:
@ -558,6 +582,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_HOST_LOOKUP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_HOST_LOOKUP))
///- iOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost))
///- MacOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_HOST_NAME_NOT_RESOLVED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final HOST_LOOKUP =
WebResourceErrorType._internalMultiPlatform('HOST_LOOKUP', () {
switch (defaultTargetPlatform) {
@ -567,6 +592,8 @@ class WebResourceErrorType {
return -1003;
case TargetPlatform.macOS:
return -1003;
case TargetPlatform.windows:
return 13;
default:
break;
}
@ -611,6 +638,7 @@ class WebResourceErrorType {
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost))
///- MacOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_DISCONNECTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final NETWORK_CONNECTION_LOST =
WebResourceErrorType._internalMultiPlatform('NETWORK_CONNECTION_LOST',
() {
@ -619,6 +647,8 @@ class WebResourceErrorType {
return -1005;
case TargetPlatform.macOS:
return -1005;
case TargetPlatform.windows:
return 11;
default:
break;
}
@ -678,6 +708,21 @@ class WebResourceErrorType {
return null;
});
///Indicates that the request redirect failed.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_REDIRECT_FAILED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final REDIRECT_FAILED =
WebResourceErrorType._internalMultiPlatform('REDIRECT_FAILED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.windows:
return 15;
default:
break;
}
return null;
});
///A redirect was specified by way of server response code, but the server didnt accompany this code with a redirect URL.
///
///**Officially Supported Platforms/Implementations**:
@ -716,6 +761,20 @@ class WebResourceErrorType {
return null;
});
///Indicates that the connection was reset.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_RESET](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final RESET = WebResourceErrorType._internalMultiPlatform('RESET', () {
switch (defaultTargetPlatform) {
case TargetPlatform.windows:
return 10;
default:
break;
}
return null;
});
///A requested resource couldn't be retrieved.
///This error can indicate a file-not-found situation, or decoding problems that prevent data from being processed correctly.
///
@ -830,12 +889,28 @@ class WebResourceErrorType {
return null;
});
///Indicates that the host is unreachable.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_SERVER_UNREACHABLE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final SERVER_UNREACHABLE =
WebResourceErrorType._internalMultiPlatform('SERVER_UNREACHABLE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.windows:
return 6;
default:
break;
}
return null;
});
///Connection timed out.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_TIMEOUT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TIMEOUT))
///- iOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout))
///- MacOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_TIMEOUT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final TIMEOUT =
WebResourceErrorType._internalMultiPlatform('TIMEOUT', () {
switch (defaultTargetPlatform) {
@ -845,6 +920,8 @@ class WebResourceErrorType {
return -1001;
case TargetPlatform.macOS:
return -1001;
case TargetPlatform.windows:
return 7;
default:
break;
}
@ -887,12 +964,28 @@ class WebResourceErrorType {
return null;
});
///Indicates that an unexpected error occurred.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_UNEXPECTED_ERROR](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final UNEXPECTED_ERROR =
WebResourceErrorType._internalMultiPlatform('UNEXPECTED_ERROR', () {
switch (defaultTargetPlatform) {
case TargetPlatform.windows:
return 16;
default:
break;
}
return null;
});
///The URL Loading System encountered an error that it cant interpret.
///
///**Officially Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNKNOWN))
///- iOS ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown))
///- MacOS ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final UNKNOWN =
WebResourceErrorType._internalMultiPlatform('UNKNOWN', () {
switch (defaultTargetPlatform) {
@ -902,6 +995,8 @@ class WebResourceErrorType {
return -1;
case TargetPlatform.macOS:
return -1;
case TargetPlatform.windows:
return 0;
default:
break;
}
@ -982,6 +1077,7 @@ class WebResourceErrorType {
///**Officially Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired))
///- MacOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired))
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final USER_AUTHENTICATION_REQUIRED =
WebResourceErrorType._internalMultiPlatform(
'USER_AUTHENTICATION_REQUIRED', () {
@ -990,6 +1086,8 @@ class WebResourceErrorType {
return -1013;
case TargetPlatform.macOS:
return -1013;
case TargetPlatform.windows:
return 17;
default:
break;
}
@ -1016,6 +1114,22 @@ class WebResourceErrorType {
return null;
});
///Indicates that user lacks proper authentication credentials for a proxy server.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status))
static final VALID_PROXY_AUTHENTICATION_REQUIRED =
WebResourceErrorType._internalMultiPlatform(
'VALID_PROXY_AUTHENTICATION_REQUIRED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.windows:
return 18;
default:
break;
}
return null;
});
///A server reported that a URL has a non-zero content length, but terminated the network connection gracefully without sending any data.
///
///**Officially Supported Platforms/Implementations**:
@ -1057,6 +1171,7 @@ class WebResourceErrorType {
WebResourceErrorType.CANNOT_WRITE_TO_FILE,
WebResourceErrorType.CLIENT_CERTIFICATE_REJECTED,
WebResourceErrorType.CLIENT_CERTIFICATE_REQUIRED,
WebResourceErrorType.CONNECTION_ABORTED,
WebResourceErrorType.DATA_LENGTH_EXCEEDS_MAXIMUM,
WebResourceErrorType.DATA_NOT_ALLOWED,
WebResourceErrorType.DOWNLOAD_DECODING_FAILED_MID_STREAM,
@ -1072,17 +1187,21 @@ class WebResourceErrorType {
WebResourceErrorType.NOT_CONNECTED_TO_INTERNET,
WebResourceErrorType.NO_PERMISSIONS_TO_READ_FILE,
WebResourceErrorType.PROXY_AUTHENTICATION,
WebResourceErrorType.REDIRECT_FAILED,
WebResourceErrorType.REDIRECT_TO_NON_EXISTENT_LOCATION,
WebResourceErrorType.REQUEST_BODY_STREAM_EXHAUSTED,
WebResourceErrorType.RESET,
WebResourceErrorType.RESOURCE_UNAVAILABLE,
WebResourceErrorType.SECURE_CONNECTION_FAILED,
WebResourceErrorType.SERVER_CERTIFICATE_HAS_BAD_DATE,
WebResourceErrorType.SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT,
WebResourceErrorType.SERVER_CERTIFICATE_NOT_YET_VALID,
WebResourceErrorType.SERVER_CERTIFICATE_UNTRUSTED,
WebResourceErrorType.SERVER_UNREACHABLE,
WebResourceErrorType.TIMEOUT,
WebResourceErrorType.TOO_MANY_REDIRECTS,
WebResourceErrorType.TOO_MANY_REQUESTS,
WebResourceErrorType.UNEXPECTED_ERROR,
WebResourceErrorType.UNKNOWN,
WebResourceErrorType.UNSAFE_RESOURCE,
WebResourceErrorType.UNSUPPORTED_AUTH_SCHEME,
@ -1090,6 +1209,7 @@ class WebResourceErrorType {
WebResourceErrorType.USER_AUTHENTICATION_FAILED,
WebResourceErrorType.USER_AUTHENTICATION_REQUIRED,
WebResourceErrorType.USER_CANCELLED_AUTHENTICATION,
WebResourceErrorType.VALID_PROXY_AUTHENTICATION_REQUIRED,
WebResourceErrorType.ZERO_BYTE_RESOURCE,
].toSet();

View File

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

View File

@ -20,10 +20,13 @@ class WindowType {
///
///**Officially Supported Platforms/Implementations**:
///- MacOS
///- Windows
static final CHILD = WindowType._internalMultiPlatform('CHILD', () {
switch (defaultTargetPlatform) {
case TargetPlatform.macOS:
return 'CHILD';
case TargetPlatform.windows:
return 'CHILD';
default:
break;
}
@ -48,10 +51,13 @@ class WindowType {
///
///**Officially Supported Platforms/Implementations**:
///- MacOS
///- Windows
static final WINDOW = WindowType._internalMultiPlatform('WINDOW', () {
switch (defaultTargetPlatform) {
case TargetPlatform.macOS:
return 'WINDOW';
case TargetPlatform.windows:
return 'WINDOW';
default:
break;
}

View File

@ -33,6 +33,7 @@ class PlatformWebStorageCreationParams {
///- iOS
///- MacOS
///- Web
///- Windows
///{@endtemplate}
abstract class PlatformWebStorage extends PlatformInterface
implements Disposable {

View File

@ -0,0 +1,2 @@
export 'platform_webview_environment.dart';
export 'webview_environment_settings.dart' show WebViewEnvironmentSettings;

View File

@ -0,0 +1,147 @@
import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import '../debug_logging_settings.dart';
import '../inappwebview_platform.dart';
import '../types/disposable.dart';
import 'webview_environment_settings.dart';
/// Object specifying creation parameters for creating a [PlatformWebViewEnvironment].
///
/// Platform specific implementations can add additional fields by extending
/// this class.
@immutable
class PlatformWebViewEnvironmentCreationParams {
/// Used by the platform implementation to create a new [PlatformWebViewEnvironment].
const PlatformWebViewEnvironmentCreationParams({this.settings});
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.settings}
final WebViewEnvironmentSettings? settings;
}
///Controls a WebView Environment used by WebView instances.
///Use [dispose] when not needed anymore to release references.
///
///**Officially Supported Platforms/Implementations**:
///- Windows
abstract class PlatformWebViewEnvironment extends PlatformInterface
implements Disposable {
///Debug settings used by [PlatformWebViewEnvironment].
static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(
maxLogMessageLength: 1000
);
/// Creates a new [PlatformInAppWebViewController]
factory PlatformWebViewEnvironment(
PlatformWebViewEnvironmentCreationParams params) {
assert(
InAppWebViewPlatform.instance != null,
'A platform implementation for `flutter_inappwebview` has not been set. Please '
'ensure that an implementation of `InAppWebViewPlatform` has been set to '
'`InAppWebViewPlatform.instance` before use. For unit testing, '
'`InAppWebViewPlatform.instance` can be set with your own test implementation.',
);
final PlatformWebViewEnvironment webViewEnvironment =
InAppWebViewPlatform.instance!
.createPlatformWebViewEnvironment(params);
PlatformInterface.verify(webViewEnvironment, _token);
return webViewEnvironment;
}
/// Creates a new [PlatformWebViewEnvironment] to access static methods.
factory PlatformWebViewEnvironment.static() {
assert(
InAppWebViewPlatform.instance != null,
'A platform implementation for `flutter_inappwebview` has not been set. Please '
'ensure that an implementation of `InAppWebViewPlatform` has been set to '
'`InAppWebViewPlatform.instance` before use. For unit testing, '
'`InAppWebViewPlatform.instance` can be set with your own test implementation.',
);
final PlatformWebViewEnvironment webViewEnvironment =
InAppWebViewPlatform.instance!
.createPlatformWebViewEnvironmentStatic();
PlatformInterface.verify(webViewEnvironment, _token);
return webViewEnvironment;
}
/// Used by the platform implementation to create a new [PlatformWebViewEnvironment].
///
/// Should only be used by platform implementations because they can't extend
/// a class that only contains a factory constructor.
@protected
PlatformWebViewEnvironment.implementation(this.params)
: super(token: _token);
static final Object _token = Object();
/// The parameters used to initialize the [PlatformWebViewEnvironment].
final PlatformWebViewEnvironmentCreationParams params;
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.id}
/// WebView Environment ID.
///{@endtemplate}
String get id =>
throw UnimplementedError('id is not implemented on the current platform');
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.settings}
/// WebView Environment settings.
///{@endtemplate}
WebViewEnvironmentSettings? get settings => params.settings;
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.create}
///Creates the [PlatformWebViewEnvironment] using [settings].
///
///Check https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions
///for more info.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - CreateCoreWebView2EnvironmentWithOptions](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions))
///{@endtemplate}
Future<PlatformWebViewEnvironment> create(
{WebViewEnvironmentSettings? settings}) {
throw UnimplementedError(
'create is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
///Get the browser version info including channel name if it is not the WebView2 Runtime.
///
///Channel names are Beta, Dev, and Canary.
///If an override exists for the browserExecutableFolder or the channel preference, the override is used.
///If an override is not specified, then the parameter value passed to [getAvailableVersion] is used.
///Returns `null` if it fails to find an installed WebView2 runtime or non-stable Microsoft Edge installation.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - GetAvailableCoreWebView2BrowserVersionString](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions))
///{@endtemplate}
Future<String?> getAvailableVersion(
{String? browserExecutableFolder}) {
throw UnimplementedError(
'getAvailableVersion is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.compareBrowserVersions}
///This method is for anyone want to compare version correctly to determine which version is newer, older or same.
///
///Use it to determine whether to use webview2 or certain feature based upon version.
///Sets the value of result to `-1`, `0` or `1` if version1 is less than, equal or greater than version2 respectively.
///Returns `null` if it fails to parse any of the version strings.
///Directly use the version info obtained from [getAvailableVersion] with input, channel information is ignored.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - CompareBrowserVersions](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions))
///{@endtemplate}
Future<int?> compareBrowserVersions(
{required String version1, required String version2}) {
throw UnimplementedError(
'compareBrowserVersions is not implemented on the current platform');
}
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose}
///Disposes the WebView Environment reference.
///{@endtemplate}
Future<void> dispose() {
throw UnimplementedError(
'dispose is not implemented on the current platform');
}
}

View File

@ -0,0 +1,91 @@
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import 'platform_webview_environment.dart';
part 'webview_environment_settings.g.dart';
///This class represents all the [PlatformWebViewEnvironment] settings available.
///
///The [browserExecutableFolder], [userDataFolder] and [additionalBrowserArguments]
///may be overridden by values either specified in environment variables or in the registry.
@SupportedPlatforms(platforms: [
WindowsPlatform()
])
@ExchangeableObject(copyMethod: true)
class WebViewEnvironmentSettings_ {
///Use [browserExecutableFolder] to specify whether WebView2 controls use a fixed
///or installed version of the WebView2 Runtime that exists on a user machine.
///To use a fixed version of the WebView2 Runtime, pass the folder path that contains
///the fixed version of the WebView2 Runtime to [browserExecutableFolder].
///BrowserExecutableFolder supports both relative (to the application's executable) and absolute files paths.
///To create WebView2 controls that use the installed version of the WebView2 Runtime that exists on user machines,
///pass a `null` or empty string to [browserExecutableFolder].
///In this scenario, the API tries to find a compatible version of the WebView2 Runtime
///that is installed on the user machine (first at the machine level, and then per user) using the selected channel preference.
///The path of fixed version of the WebView2 Runtime should not contain `\Edge\Application\`.
///When such a path is used, the API fails with `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)`.
///
///The default channel search order is the WebView2 Runtime, Beta, Dev, and Canary.
///When an override `WEBVIEW2_RELEASE_CHANNEL_PREFERENCE` environment variable or
///applicable `releaseChannelPreference` registry value is set to `1`, the channel search order is reversed.
@SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'CreateCoreWebView2EnvironmentWithOptions.browserExecutableFolder', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions')
])
final String? browserExecutableFolder;
///You may specify the [userDataFolder] to change the default user data folder location for WebView2.
///The path is either an absolute file path or a relative file path that is interpreted as relative
///to the compiled code for the current process.
///For UWP apps, the default user data folder is the app data folder for the package.
///For non-UWP apps, the default user data (`{Executable File Name}.WebView2`) folder
///is created in the same directory next to the compiled code for the app.
///WebView2 creation fails if the compiled code is running in a directory in which the
///process does not have permission to create a new directory.
///The app is responsible to clean up the associated user data folder when it is done.
///
///**NOTE**: As a browser process may be shared among WebViews,
///WebView creation fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if the specified
///options does not match the options of the WebViews that are currently
///running in the shared browser process.
@SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'CreateCoreWebView2EnvironmentWithOptions.userDataFolder', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions')
])
final String? userDataFolder;
///If there are multiple switches, there should be a space in between them.
///The one exception is if multiple features are being enabled/disabled for a single switch,
///in which case the features should be comma-seperated.
///Example: `"--disable-features=feature1,feature2 --some-other-switch --do-something"`
@SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_AdditionalBrowserArguments', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_additionalbrowserarguments')
])
final String? additionalBrowserArguments;
///This property is used to enable single sign on with Azure Active Directory (AAD)
///and personal Microsoft Account (MSA) resources inside WebView.
@SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_AllowSingleSignOnUsingOSPrimaryAccount', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_allowsinglesignonusingosprimaryaccount')
])
final bool? allowSingleSignOnUsingOSPrimaryAccount;
///The default display language for WebView.
@SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_Language', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_language')
])
final String? language;
///Specifies the version of the WebView2 Runtime binaries required to be compatible with your app.
@SupportedPlatforms(platforms: [
WindowsPlatform(apiName: 'ICoreWebView2EnvironmentOptions.put_TargetCompatibleBrowserVersion', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_targetcompatiblebrowserversion')
])
final String? targetCompatibleBrowserVersion;
WebViewEnvironmentSettings_({
this.browserExecutableFolder,
this.userDataFolder,
this.additionalBrowserArguments,
this.allowSingleSignOnUsingOSPrimaryAccount,
this.language,
this.targetCompatibleBrowserVersion
});
}

View File

@ -0,0 +1,140 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'webview_environment_settings.dart';
// **************************************************************************
// ExchangeableObjectGenerator
// **************************************************************************
///This class represents all the [PlatformWebViewEnvironment] settings available.
///
///The [browserExecutableFolder], [userDataFolder] and [additionalBrowserArguments]
///may be overridden by values either specified in environment variables or in the registry.
///
///**Officially Supported Platforms/Implementations**:
///- Windows
class WebViewEnvironmentSettings {
///If there are multiple switches, there should be a space in between them.
///The one exception is if multiple features are being enabled/disabled for a single switch,
///in which case the features should be comma-seperated.
///Example: `"--disable-features=feature1,feature2 --some-other-switch --do-something"`
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_AdditionalBrowserArguments](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_additionalbrowserarguments))
final String? additionalBrowserArguments;
///This property is used to enable single sign on with Azure Active Directory (AAD)
///and personal Microsoft Account (MSA) resources inside WebView.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_AllowSingleSignOnUsingOSPrimaryAccount](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_allowsinglesignonusingosprimaryaccount))
final bool? allowSingleSignOnUsingOSPrimaryAccount;
///Use [browserExecutableFolder] to specify whether WebView2 controls use a fixed
///or installed version of the WebView2 Runtime that exists on a user machine.
///To use a fixed version of the WebView2 Runtime, pass the folder path that contains
///the fixed version of the WebView2 Runtime to [browserExecutableFolder].
///BrowserExecutableFolder supports both relative (to the application's executable) and absolute files paths.
///To create WebView2 controls that use the installed version of the WebView2 Runtime that exists on user machines,
///pass a `null` or empty string to [browserExecutableFolder].
///In this scenario, the API tries to find a compatible version of the WebView2 Runtime
///that is installed on the user machine (first at the machine level, and then per user) using the selected channel preference.
///The path of fixed version of the WebView2 Runtime should not contain `\Edge\Application\`.
///When such a path is used, the API fails with `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)`.
///
///The default channel search order is the WebView2 Runtime, Beta, Dev, and Canary.
///When an override `WEBVIEW2_RELEASE_CHANNEL_PREFERENCE` environment variable or
///applicable `releaseChannelPreference` registry value is set to `1`, the channel search order is reversed.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - CreateCoreWebView2EnvironmentWithOptions.browserExecutableFolder](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions))
final String? browserExecutableFolder;
///The default display language for WebView.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_Language](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_language))
final String? language;
///Specifies the version of the WebView2 Runtime binaries required to be compatible with your app.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_TargetCompatibleBrowserVersion](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_targetcompatiblebrowserversion))
final String? targetCompatibleBrowserVersion;
///You may specify the [userDataFolder] to change the default user data folder location for WebView2.
///The path is either an absolute file path or a relative file path that is interpreted as relative
///to the compiled code for the current process.
///For UWP apps, the default user data folder is the app data folder for the package.
///For non-UWP apps, the default user data (`{Executable File Name}.WebView2`) folder
///is created in the same directory next to the compiled code for the app.
///WebView2 creation fails if the compiled code is running in a directory in which the
///process does not have permission to create a new directory.
///The app is responsible to clean up the associated user data folder when it is done.
///
///**NOTE**: As a browser process may be shared among WebViews,
///WebView creation fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if the specified
///options does not match the options of the WebViews that are currently
///running in the shared browser process.
///
///**Officially Supported Platforms/Implementations**:
///- Windows ([Official API - CreateCoreWebView2EnvironmentWithOptions.userDataFolder](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions))
final String? userDataFolder;
///
///**Officially Supported Platforms/Implementations**:
///- Windows
WebViewEnvironmentSettings(
{this.additionalBrowserArguments,
this.allowSingleSignOnUsingOSPrimaryAccount,
this.browserExecutableFolder,
this.language,
this.targetCompatibleBrowserVersion,
this.userDataFolder});
///Gets a possible [WebViewEnvironmentSettings] instance from a [Map] value.
static WebViewEnvironmentSettings? fromMap(Map<String, dynamic>? map) {
if (map == null) {
return null;
}
final instance = WebViewEnvironmentSettings(
additionalBrowserArguments: map['additionalBrowserArguments'],
allowSingleSignOnUsingOSPrimaryAccount:
map['allowSingleSignOnUsingOSPrimaryAccount'],
browserExecutableFolder: map['browserExecutableFolder'],
language: map['language'],
targetCompatibleBrowserVersion: map['targetCompatibleBrowserVersion'],
userDataFolder: map['userDataFolder'],
);
return instance;
}
///Converts instance to a map.
Map<String, dynamic> toMap() {
return {
"additionalBrowserArguments": additionalBrowserArguments,
"allowSingleSignOnUsingOSPrimaryAccount":
allowSingleSignOnUsingOSPrimaryAccount,
"browserExecutableFolder": browserExecutableFolder,
"language": language,
"targetCompatibleBrowserVersion": targetCompatibleBrowserVersion,
"userDataFolder": userDataFolder,
};
}
///Converts instance to a map.
Map<String, dynamic> toJson() {
return toMap();
}
///Returns a copy of WebViewEnvironmentSettings.
WebViewEnvironmentSettings copy() {
return WebViewEnvironmentSettings.fromMap(toMap()) ??
WebViewEnvironmentSettings();
}
@override
String toString() {
return 'WebViewEnvironmentSettings{additionalBrowserArguments: $additionalBrowserArguments, allowSingleSignOnUsingOSPrimaryAccount: $allowSingleSignOnUsingOSPrimaryAccount, browserExecutableFolder: $browserExecutableFolder, language: $language, targetCompatibleBrowserVersion: $targetCompatibleBrowserVersion, userDataFolder: $userDataFolder}';
}
}

View File

@ -1,6 +1,6 @@
name: flutter_inappwebview_platform_interface
description: A common platform interface for the flutter_inappwebview plugin.
version: 1.0.10
version: 1.0.11
homepage: https://inappwebview.dev/
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_platform_interface
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues

29
flutter_inappwebview_windows/.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
# 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/
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: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9"
channel: "stable"
project_type: plugin
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: windows
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
# 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_windows
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,15 @@
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
unnecessary_cast: ignore
unnecessary_import: ignore

View File

@ -0,0 +1,43 @@
# 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
.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_windows_example
Demonstrates how to use the flutter_inappwebview_windows 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,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: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
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_platform_interface:
dependency: transitive
description:
path: "../../flutter_inappwebview_platform_interface"
relative: true
source: path
version: "1.0.10"
flutter_inappwebview_windows:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.0.11"
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: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.10.0"
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: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
url: "https://pub.dev"
source: hosted
version: "3.1.2"
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: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
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: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
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: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
url: "https://pub.dev"
source: hosted
version: "11.10.0"
web:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.3.0"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
sdks:
dart: ">=3.2.3 <4.0.0"
flutter: ">=3.0.0"

View File

@ -0,0 +1,85 @@
name: flutter_inappwebview_windows_example
description: "Demonstrates how to use the flutter_inappwebview_windows 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.2.3 <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_windows:
# When depending on this package from a real application you should use:
# flutter_inappwebview_windows: ^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,17 @@
flutter/ephemeral/
# Visual Studio user-specific files.
*.suo
*.user
*.userosscache
*.sln.docstates
# Visual Studio build-related files.
x64/
x86/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

View File

@ -0,0 +1,110 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(flutter_inappwebview_windows_example LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "flutter_inappwebview_windows_example")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(VERSION 3.14...3.25)
# Define build configuration option.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
endif()
# Define settings for the Profile build mode.
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
# Use Unicode for all projects.
add_definitions(-DUNICODE -D_UNICODE)
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
endfunction()
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
# Enable the test target.
set(include_flutter_inappwebview_windows_tests TRUE)
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)

View File

@ -0,0 +1,109 @@
# This file controls Flutter-level build steps. It should not be edited.
cmake_minimum_required(VERSION 3.14)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()
# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"flutter_export.h"
"flutter_windows.h"
"flutter_messenger.h"
"flutter_plugin_registrar.h"
"flutter_texture_registrar.h"
)
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
add_dependencies(flutter flutter_assemble)
# === Wrapper ===
list(APPEND CPP_WRAPPER_SOURCES_CORE
"core_implementations.cc"
"standard_codec.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
"plugin_registrar.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
list(APPEND CPP_WRAPPER_SOURCES_APP
"flutter_engine.cc"
"flutter_view_controller.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
# Wrapper sources needed for a plugin.
add_library(flutter_wrapper_plugin STATIC
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
)
apply_standard_settings(flutter_wrapper_plugin)
set_target_properties(flutter_wrapper_plugin PROPERTIES
POSITION_INDEPENDENT_CODE ON)
set_target_properties(flutter_wrapper_plugin PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
target_include_directories(flutter_wrapper_plugin PUBLIC
"${WRAPPER_ROOT}/include"
)
add_dependencies(flutter_wrapper_plugin flutter_assemble)
# Wrapper sources needed for the runner.
add_library(flutter_wrapper_app STATIC
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_APP}
)
apply_standard_settings(flutter_wrapper_app)
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
target_include_directories(flutter_wrapper_app PUBLIC
"${WRAPPER_ROOT}/include"
)
add_dependencies(flutter_wrapper_app flutter_assemble)
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
${CPP_WRAPPER_SOURCES_APP}
${PHONY_OUTPUT}
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
${CPP_WRAPPER_SOURCES_APP}
)

View File

@ -0,0 +1,14 @@
//
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
}

View File

@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter/plugin_registry.h>
// Registers Flutter plugins.
void RegisterPlugins(flutter::PluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_

View File

@ -0,0 +1,24 @@
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
flutter_inappwebview_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
"utils.cpp"
"win32_window.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
"Runner.rc"
"runner.exe.manifest"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)

View File

@ -0,0 +1,121 @@
// Microsoft Visual C++ generated resource script.
//
#pragma code_page(65001)
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APP_ICON ICON "resources\\app_icon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0,0
#endif
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_AS_NUMBER
PRODUCTVERSION VERSION_AS_NUMBER
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.pichillilorenzo" "\0"
VALUE "FileDescription", "flutter_inappwebview_windows_example" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "flutter_inappwebview_windows_example" "\0"
VALUE "LegalCopyright", "Copyright (C) 2023 com.pichillilorenzo. All rights reserved." "\0"
VALUE "OriginalFilename", "flutter_inappwebview_windows_example.exe" "\0"
VALUE "ProductName", "flutter_inappwebview_windows_example" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,71 @@
#include "flutter_window.h"
#include <optional>
#include "flutter/generated_plugin_registrant.h"
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
: project_(project) {}
FlutterWindow::~FlutterWindow() {}
bool FlutterWindow::OnCreate() {
if (!Win32Window::OnCreate()) {
return false;
}
RECT frame = GetClientArea();
// The size here must match the window dimensions to avoid unnecessary surface
// creation / destruction in the startup path.
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
frame.right - frame.left, frame.bottom - frame.top, project_);
// Ensure that basic setup of the controller was successful.
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
return false;
}
RegisterPlugins(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());
flutter_controller_->engine()->SetNextFrameCallback([&]() {
this->Show();
});
// Flutter can complete the first frame before the "show window" callback is
// registered. The following call ensures a frame is pending to ensure the
// window is shown. It is a no-op if the first frame hasn't completed yet.
flutter_controller_->ForceRedraw();
return true;
}
void FlutterWindow::OnDestroy() {
if (flutter_controller_) {
flutter_controller_ = nullptr;
}
Win32Window::OnDestroy();
}
LRESULT
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
// Give Flutter, including plugins, an opportunity to handle window messages.
if (flutter_controller_) {
std::optional<LRESULT> result =
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
lparam);
if (result) {
return *result;
}
}
switch (message) {
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
}
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
}

View File

@ -0,0 +1,33 @@
#ifndef RUNNER_FLUTTER_WINDOW_H_
#define RUNNER_FLUTTER_WINDOW_H_
#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
#include <memory>
#include "win32_window.h"
// A window that does nothing but host a Flutter view.
class FlutterWindow : public Win32Window {
public:
// Creates a new FlutterWindow hosting a Flutter view running |project|.
explicit FlutterWindow(const flutter::DartProject& project);
virtual ~FlutterWindow();
protected:
// Win32Window:
bool OnCreate() override;
void OnDestroy() override;
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
LPARAM const lparam) noexcept override;
private:
// The project to run.
flutter::DartProject project_;
// The Flutter instance hosted by this window.
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
};
#endif // RUNNER_FLUTTER_WINDOW_H_

View File

@ -0,0 +1,43 @@
#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
#include <windows.h>
#include "flutter_window.h"
#include "utils.h"
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
CreateAndAttachConsole();
}
// Initialize COM, so that it is available for use in the library and/or
// plugins.
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
flutter::DartProject project(L"data");
std::vector<std::string> command_line_arguments =
GetCommandLineArguments();
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.Create(L"flutter_inappwebview_windows_example", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);
::MSG msg;
while (::GetMessage(&msg, nullptr, 0, 0)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
::CoUninitialize();
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Runner.rc
//
#define IDI_APP_ICON 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

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