diff --git a/.all-contributorsrc b/.all-contributorsrc
index 27fa03dad..33a5556f6 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -766,6 +766,105 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "nnnlog",
+ "name": "nlog (solrin)",
+ "avatar_url": "https://avatars.githubusercontent.com/u/20399222?v=4",
+ "profile": "https://nlog.dev",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "Murmurl912",
+ "name": "Murmurl912",
+ "avatar_url": "https://avatars.githubusercontent.com/u/36264246?v=4",
+ "profile": "https://github.com/Murmurl912",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "bschulz87",
+ "name": "Benjamin Schulz",
+ "avatar_url": "https://avatars.githubusercontent.com/u/30199362?v=4",
+ "profile": "https://github.com/bschulz87",
+ "contributions": [
+ "ideas"
+ ]
+ },
+ {
+ "login": "ShuheiSuzuki-07",
+ "name": "seal-app",
+ "avatar_url": "https://avatars.githubusercontent.com/u/118415919?v=4",
+ "profile": "https://github.com/ShuheiSuzuki-07",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "takuyaaaaaaahaaaaaa",
+ "name": "Takuya Tominaga",
+ "avatar_url": "https://avatars.githubusercontent.com/u/31458194?v=4",
+ "profile": "https://github.com/takuyaaaaaaahaaaaaa",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "yamaha252",
+ "name": "Sergey",
+ "avatar_url": "https://avatars.githubusercontent.com/u/4444068?v=4",
+ "profile": "https://github.com/yamaha252",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "lyb5834",
+ "name": "yuanbo li",
+ "avatar_url": "https://avatars.githubusercontent.com/u/16265810?v=4",
+ "profile": "https://github.com/lyb5834",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "Mecharyry",
+ "name": "Ryan Feline",
+ "avatar_url": "https://avatars.githubusercontent.com/u/3380092?v=4",
+ "profile": "https://github.com/Mecharyry",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "fuzzybinary",
+ "name": "Jeff Ward",
+ "avatar_url": "https://avatars.githubusercontent.com/u/249982?v=4",
+ "profile": "https://fuzzybinary.com",
+ "contributions": [
+ "test"
+ ]
+ },
+ {
+ "login": "yerkejs",
+ "name": "Yelzhan Yerkebulan",
+ "avatar_url": "https://avatars.githubusercontent.com/u/33483071?v=4",
+ "profile": "https://hero.io",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "GooRingX",
+ "name": "GooRingX",
+ "avatar_url": "https://avatars.githubusercontent.com/u/167741400?v=4",
+ "profile": "https://github.com/GooRingX",
+ "contributions": [
+ "code"
+ ]
}
],
"contributorsPerLine": 7,
diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml
index 37a9593d5..13ffa0832 100644
--- a/.github/workflows/stale.yaml
+++ b/.github/workflows/stale.yaml
@@ -2,7 +2,7 @@ name: Close Stale Issues
on:
schedule:
- - cron: '0 * * * *' # Run every hour
+ - cron: '0 0 * * *' # Run every day at midnight
jobs:
close-issues:
diff --git a/README.md b/README.md
index fe2d03493..6d63860ad 100755
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@

-[](#contributors-)
+[](#contributors-)
[](https://pub.dartlang.org/packages/flutter_inappwebview)
@@ -191,6 +191,21 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 Gray Mackall 💻 |
 Pavel Mazhnik 💻 |
+
+  nlog (solrin) 💻 |
+  Murmurl912 💻 |
+  Benjamin Schulz 🤔 |
+  seal-app 💻 |
+  Takuya Tominaga 💻 |
+  Sergey 💻 |
+  yuanbo li 💻 |
+
+
+  Ryan Feline 💻 |
+  Jeff Ward ⚠️ |
+  Yelzhan Yerkebulan 💻 |
+  GooRingX 💻 |
+
diff --git a/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md b/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md
index b7586c319..81ce60287 100755
--- a/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md
+++ b/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.2.0
+
+- Updated `ExchangeableEnum` and `ExchangeableObjectProperty`.
+
## 1.1.1
- Added `ExchangeableObject.fromMapForceAllInline`.
diff --git a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_enum.dart b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_enum.dart
index b69902497..ea66483b4 100644
--- a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_enum.dart
+++ b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_enum.dart
@@ -4,6 +4,10 @@ class ExchangeableEnum {
final bool fromValueMethod;
final bool toNativeValueMethod;
final bool fromNativeValueMethod;
+ final bool nameMethod;
+ final bool toNameMethod;
+ final bool byNameMethod;
+ final bool asNameMapMethod;
final bool toStringMethod;
final bool hashCodeMethod;
final bool equalsOperator;
@@ -15,6 +19,10 @@ class ExchangeableEnum {
this.fromValueMethod = true,
this.toNativeValueMethod = true,
this.fromNativeValueMethod = true,
+ this.nameMethod = true,
+ this.toNameMethod = true,
+ this.byNameMethod = true,
+ this.asNameMapMethod = true,
this.toStringMethod = true,
this.hashCodeMethod = true,
this.equalsOperator = true,
diff --git a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object_property.dart b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object_property.dart
index 14fa2eae5..9ffd83955 100644
--- a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object_property.dart
+++ b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object_property.dart
@@ -1,9 +1,17 @@
class ExchangeableObjectProperty {
final Function? serializer;
final Function? deserializer;
+ final bool deprecatedUseNewFieldNameInConstructor;
+ final bool deprecatedUseNewFieldNameInFromMapMethod;
+ final bool leaveDeprecatedInFromMapMethod;
+ final bool leaveDeprecatedInToMapMethod;
const ExchangeableObjectProperty({
this.serializer,
- this.deserializer
+ this.deserializer,
+ this.deprecatedUseNewFieldNameInConstructor = true,
+ this.deprecatedUseNewFieldNameInFromMapMethod = true,
+ this.leaveDeprecatedInFromMapMethod = false,
+ this.leaveDeprecatedInToMapMethod = false,
});
}
diff --git a/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml b/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml
index 215aca267..64e918ec7 100755
--- a/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml
+++ b/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_inappwebview_internal_annotations
description: Internal annotations used by the generator of flutter_inappwebview plugin
-version: 1.1.1
+version: 1.2.0
homepage: https://github.com/pichillilorenzo/flutter_inappwebview
environment:
diff --git a/dev_packages/generators/lib/src/exchangeable_enum_generator.dart b/dev_packages/generators/lib/src/exchangeable_enum_generator.dart
index c7802cfae..2d602bba7 100644
--- a/dev_packages/generators/lib/src/exchangeable_enum_generator.dart
+++ b/dev_packages/generators/lib/src/exchangeable_enum_generator.dart
@@ -204,13 +204,13 @@ class ExchangeableEnumGenerator
}
if (annotation.read("fromValueMethod").boolValue && (!visitor.methods.containsKey("fromValue") ||
- Util.methodHasIgnore(visitor.methods['fromNativeValue']!))) {
+ Util.methodHasIgnore(visitor.methods['fromValue']!))) {
final hasBitwiseOrOperator =
annotation.read("bitwiseOrOperator").boolValue;
classBuffer.writeln("""
///Gets a possible [$extClassName] instance from [${enumValue.type}] value.
static $extClassName? fromValue(${enumValue.type}${!Util.typeIsNullable(enumValue.type) ? '?' : ''} value) {
- if (value != null) {
+ if (value != null) {
try {
return $extClassName.values
.firstWhere((element) => element.toValue() == value);
@@ -230,7 +230,7 @@ class ExchangeableEnumGenerator
classBuffer.writeln("""
///Gets a possible [$extClassName] instance from a native value.
static $extClassName? fromNativeValue(${enumNativeValue.type}${!Util.typeIsNullable(enumNativeValue.type) ? '?' : ''} value) {
- if (value != null) {
+ if (value != null) {
try {
return $extClassName.values
.firstWhere((element) => element.toNativeValue() == value);
@@ -243,6 +243,44 @@ class ExchangeableEnumGenerator
""");
}
+ if (annotation.read("nameMethod").boolValue && annotation.read("byNameMethod").boolValue &&
+ (!visitor.methods.containsKey("byName") || Util.methodHasIgnore(visitor.methods['byName']!))) {
+ classBuffer.writeln("""
+ /// Gets a possible [$extClassName] instance value with name [name].
+ ///
+ /// Goes through [$extClassName.values] looking for a value with
+ /// name [name], as reported by [$extClassName.name].
+ /// Returns the first value with the given name, otherwise `null`.
+ static $extClassName? byName(String? name) {
+ if (name != null) {
+ try {
+ return $extClassName.values
+ .firstWhere((element) => element.name() == name);
+ } catch (e) {
+ return null;
+ }
+ }
+ return null;
+ }
+ """);
+ }
+
+ if (annotation.read("nameMethod").boolValue && annotation.read("asNameMapMethod").boolValue &&
+ (!visitor.methods.containsKey("asNameMap") || Util.methodHasIgnore(visitor.methods['asNameMap']!))) {
+ classBuffer.writeln("""
+ /// Creates a map from the names of [$extClassName] values to the values.
+ ///
+ /// The collection that this method is called on is expected to have
+ /// values with distinct names, like the `values` list of an enum class.
+ /// Only one value for each name can occur in the created map,
+ /// so if two or more values have the same name (either being the
+ /// same value, or being values of different enum type), at most one of
+ /// them will be represented in the returned map.
+ static Map asNameMap() =>
+ {for (final value in $extClassName.values) value.name(): value};
+ """);
+ }
+
for (final entry in methodEntriesSorted) {
final methodElement = entry.value;
if (Util.methodHasIgnore(methodElement)) {
@@ -282,6 +320,28 @@ class ExchangeableEnumGenerator
""");
}
+ if (annotation.read("nameMethod").boolValue && (!visitor.methods.containsKey("name") ||
+ Util.methodHasIgnore(visitor.methods['name']!))) {
+ classBuffer.writeln('///Gets the name of the value.');
+ classBuffer.writeln('String name() {');
+ classBuffer.writeln('switch(_value) {');
+ for (final entry in fieldEntriesSorted) {
+ final fieldName = entry.key;
+ final fieldElement = entry.value;
+ if (!fieldElement.isPrivate && fieldElement.isStatic) {
+ final fieldValue = fieldElement.computeConstantValue()?.getField("_value");
+ dynamic constantValue = fieldValue?.toIntValue();
+ if (enumValue.type.isDartCoreString) {
+ constantValue = "'${fieldValue?.toStringValue()}'";
+ }
+ classBuffer.writeln("case $constantValue: return '$fieldName';");
+ }
+ }
+ classBuffer.writeln('}');
+ classBuffer.writeln('return _value.toString();');
+ classBuffer.writeln('}');
+ }
+
if (annotation.read("hashCodeMethod").boolValue && (!visitor.fields.containsKey("hashCode") ||
Util.methodHasIgnore(visitor.methods['hashCode']!))) {
classBuffer.writeln("""
@@ -315,19 +375,23 @@ class ExchangeableEnumGenerator
if (enumValue.type.isDartCoreString) {
classBuffer.writeln('return _value;');
} else {
- classBuffer.writeln('switch(_value) {');
- for (final entry in fieldEntriesSorted) {
- final fieldName = entry.key;
- final fieldElement = entry.value;
- if (!fieldElement.isPrivate && fieldElement.isStatic) {
- final fieldValue =
- fieldElement.computeConstantValue()?.getField("_value");
- final constantValue = fieldValue?.toIntValue();
- classBuffer.writeln("case $constantValue: return '$fieldName';");
+ if (annotation.read("nameMethod").boolValue) {
+ classBuffer.writeln('return name();');
+ } else {
+ classBuffer.writeln('switch(_value) {');
+ for (final entry in fieldEntriesSorted) {
+ final fieldName = entry.key;
+ final fieldElement = entry.value;
+ if (!fieldElement.isPrivate && fieldElement.isStatic) {
+ final fieldValue =
+ fieldElement.computeConstantValue()?.getField("_value");
+ final constantValue = fieldValue?.toIntValue();
+ classBuffer.writeln("case $constantValue: return '$fieldName';");
+ }
}
+ classBuffer.writeln('}');
+ classBuffer.writeln('return _value.toString();');
}
- classBuffer.writeln('}');
- classBuffer.writeln('return _value.toString();');
}
classBuffer.writeln('}');
}
diff --git a/dev_packages/generators/lib/src/exchangeable_object_generator.dart b/dev_packages/generators/lib/src/exchangeable_object_generator.dart
index d399aaa12..498c95aa9 100644
--- a/dev_packages/generators/lib/src/exchangeable_object_generator.dart
+++ b/dev_packages/generators/lib/src/exchangeable_object_generator.dart
@@ -1,9 +1,10 @@
-import 'package:build/src/builder/build_step.dart';
-import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/analysis/results.dart';
+import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
-import 'package:source_gen/source_gen.dart';
+import 'package:build/src/builder/build_step.dart';
+import 'package:collection/collection.dart';
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
+import 'package:source_gen/source_gen.dart';
import 'model_visitor.dart';
import 'util.dart';
@@ -224,29 +225,43 @@ class ExchangeableObjectGenerator
if (!hasCustomConstructor && deprecatedFields.length > 0) {
classBuffer.writeln(' {');
for (final deprecatedField in deprecatedFields) {
- final deprecatedFieldName = deprecatedField.name;
+ final deprecatedUseNewFieldNameInConstructor = _coreCheckerObjectProperty
+ .firstAnnotationOf(deprecatedField)
+ ?.getField("deprecatedUseNewFieldNameInConstructor")
+ ?.toBoolValue() ?? true;
+ if (!deprecatedUseNewFieldNameInConstructor) {
+ continue;
+ }
+
final message = _coreCheckerDeprecated
.firstAnnotationOfExact(deprecatedField)!
.getField("message")!
- .toStringValue()!;
- final fieldName = message
+ .toStringValue()!.trim();
+ if (!message.startsWith("Use ") && !message.endsWith(" instead")) {
+ continue;
+ }
+
+ final newFieldName = message
.replaceFirst("Use ", "")
.replaceFirst(" instead", "")
.trim();
- final fieldElement = visitor.fields[fieldName];
- if (fieldElement != null) {
- final fieldTypeElement = fieldElement.type.element;
+
+ final newFieldElement = visitor.fields[newFieldName];
+ final shouldUseNewFieldName = newFieldElement != null;
+ if (shouldUseNewFieldName) {
+ final deprecatedFieldName = deprecatedField.name;
+ final fieldTypeElement = newFieldElement.type.element;
final deprecatedFieldTypeElement = deprecatedField.type.element;
- final isNullable = Util.typeIsNullable(fieldElement.type);
- var hasDefaultValue = (fieldElement is ParameterElement)
- ? (fieldElement as ParameterElement).hasDefaultValue
+ final isNullable = Util.typeIsNullable(newFieldElement.type);
+ var hasDefaultValue = (newFieldElement is ParameterElement)
+ ? (newFieldElement as ParameterElement).hasDefaultValue
: false;
if (!isNullable && hasDefaultValue) {
continue;
}
- classBuffer.write('$fieldName = $fieldName ?? ');
+ classBuffer.write('$newFieldName = $newFieldName ?? ');
if (fieldTypeElement != null && deprecatedFieldTypeElement != null) {
final deprecatedIsNullable =
Util.typeIsNullable(deprecatedField.type);
@@ -274,7 +289,7 @@ class ExchangeableObjectGenerator
} else if (deprecatedField.type
.getDisplayString(withNullability: false) ==
"Uri" &&
- fieldElement.type.getDisplayString(withNullability: false) ==
+ newFieldElement.type.getDisplayString(withNullability: false) ==
"WebUri") {
if (deprecatedIsNullable) {
classBuffer.write(
@@ -304,7 +319,8 @@ class ExchangeableObjectGenerator
final nullable = annotation.read("nullableFromMapFactory").boolValue;
classBuffer
.writeln('static $extClassName${nullable ? '?' : ''} fromMap(');
- classBuffer.writeln('Map${nullable ? '?' : ''} map');
+ classBuffer.writeln(
+ 'Map${nullable ? '?' : ''} map, {EnumMethod? enumMethod}');
classBuffer.writeln(') {');
if (nullable) {
classBuffer.writeln('if (map == null) { return null; }');
@@ -324,18 +340,59 @@ class ExchangeableObjectGenerator
!(fieldElement.type.isDartCoreFunction ||
fieldElement.type is FunctionType)) {
var value = "map['$fieldName']";
- final deprecationMessage = _coreCheckerDeprecated
- .firstAnnotationOfExact(fieldElement)
- ?.getField("message")
- ?.toStringValue();
- if (deprecationMessage != null) {
- final newFieldName = deprecationMessage
- .replaceFirst("Use ", "")
- .replaceFirst(" instead", "")
- .trim();
- value = "map['$newFieldName']";
+
+ if (fieldElement.hasDeprecated) {
+ final deprecatedUseNewFieldNameInFromMapMethod = _coreCheckerObjectProperty
+ .firstAnnotationOf(fieldElement)
+ ?.getField("deprecatedUseNewFieldNameInFromMapMethod")
+ ?.toBoolValue() ?? true;
+
+ final deprecationMessage = _coreCheckerDeprecated
+ .firstAnnotationOfExact(fieldElement)
+ ?.getField("message")
+ ?.toStringValue()?.trim();
+ if (deprecationMessage != null &&
+ deprecationMessage.startsWith("Use ") &&
+ deprecationMessage.endsWith(" instead") &&
+ deprecatedUseNewFieldNameInFromMapMethod) {
+ final newFieldName = deprecationMessage
+ .replaceFirst("Use ", "")
+ .replaceFirst(" instead", "")
+ .trim();
+ final newFieldElement = fieldElements
+ .firstWhereOrNull((element) => element.name == newFieldName);
+ final shouldUseNewFieldName = newFieldElement != null &&
+ (newFieldElement.type == fieldElement.type ||
+ (fieldElement.name.startsWith(RegExp(r'android|ios')) &&
+ fieldElement.name.toLowerCase().replaceFirst(
+ RegExp(r'android|ioswk|ios'), "") ==
+ newFieldName.toLowerCase()) ||
+ (newFieldElement.type.element != null &&
+ fieldElement.type.element != null &&
+ ((hasFromNativeValueMethod(
+ newFieldElement.type.element!) &&
+ hasFromNativeValueMethod(
+ fieldElement.type.element!) ||
+ (hasFromMapMethod(
+ newFieldElement.type.element!) &&
+ hasFromMapMethod(
+ fieldElement.type.element!))))));
+ if (shouldUseNewFieldName) {
+ value = "map['$newFieldName']";
+ }
+ } else {
+ final leaveDeprecatedInFromMapMethod = _coreCheckerObjectProperty
+ .firstAnnotationOf(fieldElement)
+ ?.getField("leaveDeprecatedInFromMapMethod")
+ ?.toBoolValue() ?? false;
+ if (!leaveDeprecatedInFromMapMethod) {
+ continue;
+ }
+ }
}
+ final mapValue = value;
+
final customDeserializer = _coreCheckerObjectProperty
.firstAnnotationOf(fieldElement)
?.getField("deserializer")
@@ -345,9 +402,10 @@ class ExchangeableObjectGenerator
customDeserializer.enclosingElement.name;
if (deserializerClassName != null) {
value =
- "$deserializerClassName.${customDeserializer.name}($value)";
+ "$deserializerClassName.${customDeserializer.name}($value, enumMethod: enumMethod)";
} else {
- value = "${customDeserializer.name}($value)";
+ value =
+ "${customDeserializer.name}($value, enumMethod: enumMethod)";
}
} else {
value = getFromMapValue(value, fieldElement.type);
@@ -355,13 +413,23 @@ class ExchangeableObjectGenerator
final constructorParameter = visitor.constructorParameters[fieldName];
final isRequiredParameter = constructorParameter != null &&
(constructorParameter.isRequiredNamed ||
- constructorParameter.isFinal || fieldElement.isFinal ||
+ constructorParameter.isFinal ||
+ fieldElement.isFinal ||
!Util.typeIsNullable(constructorParameter.type)) &&
!constructorParameter.hasDefaultValue;
- if (isRequiredParameter || fieldElement.isFinal || annotation.read("fromMapForceAllInline").boolValue) {
+ if (isRequiredParameter ||
+ fieldElement.isFinal ||
+ annotation.read("fromMapForceAllInline").boolValue) {
requiredFields.add('$fieldName: $value,');
} else {
+ final isFieldNullable = Util.typeIsNullable(fieldElement.type);
+ if (!isFieldNullable) {
+ nonRequiredFields.add("if ($mapValue != null) {");
+ }
nonRequiredFields.add("instance.$fieldName = $value;");
+ if (!isFieldNullable) {
+ nonRequiredFields.add("}");
+ }
}
}
}
@@ -401,13 +469,12 @@ class ExchangeableObjectGenerator
(!visitor.methods.containsKey("toMap") ||
Util.methodHasIgnore(visitor.methods['toMap']!))) {
classBuffer.writeln('///Converts instance to a map.');
- classBuffer.writeln('Map toMap() {');
+ classBuffer.writeln('Map toMap({EnumMethod? enumMethod}) {');
classBuffer.writeln('return {');
final fieldElements = [];
if (superClass != null) {
for (final fieldElement in superClass.element.fields) {
if (!fieldElement.isPrivate &&
- !fieldElement.hasDeprecated &&
!fieldElement.isStatic &&
!(fieldElement.type.isDartCoreFunction ||
fieldElement.type is FunctionType)) {
@@ -418,7 +485,6 @@ class ExchangeableObjectGenerator
for (final entry in fieldEntriesSorted) {
final fieldElement = entry.value;
if (!fieldElement.isPrivate &&
- !fieldElement.hasDeprecated &&
!fieldElement.isStatic &&
!(fieldElement.type.isDartCoreFunction ||
fieldElement.type is FunctionType)) {
@@ -427,10 +493,19 @@ class ExchangeableObjectGenerator
}
for (final fieldElement in fieldElements) {
if (!fieldElement.isPrivate &&
- !fieldElement.hasDeprecated &&
!fieldElement.isStatic &&
!(fieldElement.type.isDartCoreFunction ||
fieldElement.type is FunctionType)) {
+ if (fieldElement.hasDeprecated) {
+ final leaveDeprecatedInToMapMethod = _coreCheckerObjectProperty
+ .firstAnnotationOf(fieldElement)
+ ?.getField("leaveDeprecatedInToMapMethod")
+ ?.toBoolValue() ?? false;
+ if (!leaveDeprecatedInToMapMethod) {
+ continue;
+ }
+ }
+
final fieldName = fieldElement.name;
var mapValue = fieldName;
final customSerializer = _coreCheckerObjectProperty
@@ -441,9 +516,9 @@ class ExchangeableObjectGenerator
final serializerClassName = customSerializer.enclosingElement.name;
if (serializerClassName != null) {
mapValue =
- "$serializerClassName.${customSerializer.name}($mapValue)";
+ "$serializerClassName.${customSerializer.name}($mapValue, enumMethod: enumMethod)";
} else {
- mapValue = "${customSerializer.name}($mapValue)";
+ mapValue = "${customSerializer.name}($mapValue, enumMethod: enumMethod)";
}
} else {
mapValue = getToMapValue(fieldName, fieldElement.type);
@@ -459,7 +534,7 @@ class ExchangeableObjectGenerator
?.getField("toMapMergeWith")
?.toBoolValue();
if (toMapMergeWith == true) {
- classBuffer.writeln('...${methodElement.name}(),');
+ classBuffer.writeln('...${methodElement.name}(enumMethod: enumMethod),');
}
}
classBuffer.writeln('};');
@@ -526,6 +601,8 @@ class ExchangeableObjectGenerator
String getFromMapValue(String value, DartType elementType) {
final fieldTypeElement = elementType.element;
+ // remove class reference terminating with "_"
+ final classNameReference = fieldTypeElement?.name?.replaceFirst("_", "");
final isNullable = Util.typeIsNullable(elementType);
final displayString = elementType.getDisplayString(withNullability: false);
if (displayString == "Uri") {
@@ -592,23 +669,36 @@ class ExchangeableObjectGenerator
return "$value${isNullable ? '?' : ''}.cast<${genericTypes.elementAt(0)}, ${genericTypes.elementAt(1)}>()";
} else if (fieldTypeElement != null && hasFromMapMethod(fieldTypeElement)) {
final hasNullableFromMap = hasNullableFromMapFactory(fieldTypeElement);
- // remove class reference terminating with "_"
- return fieldTypeElement.name!.replaceFirst("_", "") +
- ".fromMap($value?.cast())${!isNullable && hasNullableFromMap ? '!' : ''}";
+ return classNameReference! +
+ ".fromMap($value?.cast(), enumMethod: enumMethod)${!isNullable && hasNullableFromMap ? '!' : ''}";
} else {
- final hasFromValue =
- fieldTypeElement != null && hasFromValueMethod(fieldTypeElement);
- final hasFromNativeValue = fieldTypeElement != null &&
- hasFromNativeValueMethod(fieldTypeElement);
- if (fieldTypeElement != null && (hasFromValue || hasFromNativeValue)) {
- if (hasFromNativeValue) {
- // remove class reference terminating with "_"
- value = fieldTypeElement.name!.replaceFirst("_", "") +
- '.fromNativeValue($value)';
+ final hasFromValue = fieldTypeElement != null && hasFromValueMethod(fieldTypeElement);
+ final hasFromNativeValue = fieldTypeElement != null && hasFromNativeValueMethod(fieldTypeElement);
+ final hasByName = fieldTypeElement != null && hasByNameMethod(fieldTypeElement);
+ if (fieldTypeElement != null && (hasFromValue || hasFromNativeValue || hasByName)) {
+ if ([hasFromValue, hasFromNativeValue, hasByName].where((e) => e).length > 1) {
+ String? defaultEnumMethodValue = null;
+ if (hasFromNativeValue) {
+ defaultEnumMethodValue = "EnumMethod.nativeValue";
+ } else if (hasFromValue) {
+ defaultEnumMethodValue = "EnumMethod.value";
+ } else {
+ defaultEnumMethodValue = "EnumMethod.name";
+ }
+ var wrapper = "switch (enumMethod ?? $defaultEnumMethodValue) {";
+ wrapper += "EnumMethod.nativeValue => " + (hasFromNativeValue ? classNameReference! + '.fromNativeValue($value)' : "null") + ", ";
+ wrapper += "EnumMethod.value => " + (hasFromValue ? classNameReference! + '.fromValue($value)' : "null") + ", ";
+ wrapper += "EnumMethod.name => " + (hasByName ? classNameReference! + '.byName($value)' : "null");
+ wrapper += "}";
+ value = wrapper;
} else {
- // remove class reference terminating with "_"
- value = fieldTypeElement.name!.replaceFirst("_", "") +
- '.fromValue($value)';
+ if (hasFromNativeValue) {
+ value = classNameReference! + '.fromNativeValue($value)';
+ } else if (hasFromValue) {
+ value = classNameReference! + '.fromValue($value)';
+ } else {
+ value = classNameReference! + '.byName($value)';
+ }
}
if (!isNullable) {
value += '!';
@@ -653,17 +743,35 @@ class ExchangeableObjectGenerator
} else if (fieldTypeElement != null && hasToMapMethod(fieldTypeElement)) {
return fieldName +
(Util.typeIsNullable(elementType) ? '?' : '') +
- '.toMap()';
+ '.toMap(enumMethod: enumMethod)';
} else {
- final hasToValue =
- fieldTypeElement != null && hasToValueMethod(fieldTypeElement);
- final hasToNativeValue =
- fieldTypeElement != null && hasToNativeValueMethod(fieldTypeElement);
- if (fieldTypeElement != null && (hasToValue || hasToNativeValue)) {
- if (hasToNativeValue) {
- return fieldName + (isNullable ? '?' : '') + '.toNativeValue()';
+ final hasToValue = fieldTypeElement != null && hasToValueMethod(fieldTypeElement);
+ final hasToNativeValue = fieldTypeElement != null && hasToNativeValueMethod(fieldTypeElement);
+ final hasName = fieldTypeElement != null && hasNameMethod(fieldTypeElement);
+ if (fieldTypeElement != null && (hasToValue || hasToNativeValue || hasName)) {
+ if ([hasToValue, hasToNativeValue, hasName].where((e) => e).length > 1) {
+ String? defaultEnumMethodValue = null;
+ if (hasToNativeValue) {
+ defaultEnumMethodValue = "EnumMethod.nativeValue";
+ } else if (hasToValue) {
+ defaultEnumMethodValue = "EnumMethod.value";
+ } else {
+ defaultEnumMethodValue = "EnumMethod.name";
+ }
+ var wrapper = "switch (enumMethod ?? $defaultEnumMethodValue) {";
+ wrapper += "EnumMethod.nativeValue => " + (hasToNativeValue ? (fieldName + (isNullable ? '?' : '') + '.toNativeValue()') : "null") + ", ";
+ wrapper += "EnumMethod.value => " + (hasToValue ? (fieldName + (isNullable ? '?' : '') + '.toValue()') : "null") + ", ";
+ wrapper += "EnumMethod.name => " + (hasName ? (fieldName + (isNullable ? '?' : '') + '.name()') : "null");
+ wrapper += "}";
+ return wrapper;
} else {
- return fieldName + (isNullable ? '?' : '') + '.toValue()';
+ if (hasToNativeValue) {
+ return fieldName + (isNullable ? '?' : '') + '.toNativeValue()';
+ } else if (hasToValue) {
+ return fieldName + (isNullable ? '?' : '') + '.toValue()';
+ } else {
+ return fieldName + (isNullable ? '?' : '') + '.name()';
+ }
}
}
}
@@ -787,6 +895,28 @@ class ExchangeableObjectGenerator
return false;
}
+ bool hasByNameMethod(Element element) {
+ final hasAnnotation = _coreCheckerEnum.hasAnnotationOf(element);
+ final byNameMethod = _coreCheckerEnum
+ .firstAnnotationOfExact(element)
+ ?.getField('byNameMethod')
+ ?.toBoolValue() ??
+ false;
+ if (hasAnnotation && byNameMethod) {
+ return true;
+ }
+
+ final fieldVisitor = ModelVisitor();
+ element.visitChildren(fieldVisitor);
+ for (var entry in fieldVisitor.methods.entries) {
+ if (entry.key == "byName") {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
bool hasToValueMethod(Element element) {
final hasAnnotation = _coreCheckerEnum.hasAnnotationOf(element);
final hasToValueMethod = _coreCheckerEnum
@@ -830,4 +960,26 @@ class ExchangeableObjectGenerator
return false;
}
+
+ bool hasNameMethod(Element element) {
+ final hasAnnotation = _coreCheckerEnum.hasAnnotationOf(element);
+ final hasNameMethod = _coreCheckerEnum
+ .firstAnnotationOfExact(element)
+ ?.getField('nameMethod')
+ ?.toBoolValue() ??
+ false;
+ if (hasAnnotation && hasNameMethod) {
+ return true;
+ }
+
+ final fieldVisitor = ModelVisitor();
+ element.visitChildren(fieldVisitor);
+ for (var entry in fieldVisitor.methods.entries) {
+ if (entry.key == "name") {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/dev_packages/generators/pubspec.yaml b/dev_packages/generators/pubspec.yaml
index ffa31b464..19bff4858 100755
--- a/dev_packages/generators/pubspec.yaml
+++ b/dev_packages/generators/pubspec.yaml
@@ -12,7 +12,9 @@ dependencies:
sdk: flutter
build: ^2.4.1
source_gen: ^1.5.0
- flutter_inappwebview_internal_annotations: ^1.1.1
+ collection: any
+ flutter_inappwebview_internal_annotations: ^1.2.0
+ # path: ../flutter_inappwebview_internal_annotations
dev_dependencies:
build_runner: ^2.4.12
diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md
index c74465f00..b45f23ceb 100755
--- a/flutter_inappwebview/CHANGELOG.md
+++ b/flutter_inappwebview/CHANGELOG.md
@@ -1,3 +1,165 @@
+## 6.2.0-beta.3
+
+- Updated dependencies to the latest versions for all platform implementations:
+ - `flutter_inappwebview_platform_interface`: `^1.4.0-beta.2` -> `^1.4.0-beta.3`
+ - `flutter_inappwebview_android`: `^1.2.0-beta.2` -> `^1.2.0-beta.3`
+ - `flutter_inappwebview_ios`: `^1.2.0-beta.2` -> `^1.2.0-beta.3`
+ - `flutter_inappwebview_macos`: `^1.2.0-beta.2` -> `^1.2.0-beta.3`
+ - `flutter_inappwebview_web`: `^1.2.0-beta.2` -> `^1.2.0-beta.3`
+ - `flutter_inappwebview_windows`: `^0.7.0-beta.2` -> `^0.7.0-beta.3`
+- Fixed "When useShouldInterceptAjaxRequest is true, some ajax requests doesn't work" [#2197](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2197)
+
+#### Platform Interface
+- Added `saveState`, `restoreState` methods to `PlatformInAppWebViewController` class
+- Added `useOnAjaxReadyStateChange`, `useOnAjaxProgress`, `useOnShowFileChooser` properties to `InAppWebViewSettings`
+- Added `onShowFileChooser` WebView events
+
+#### Android Platform
+- Implemented `saveState`, `restoreState` InAppWebViewController methods
+- Implemented `onShowFileChooser` WebView event
+- Merged "Android: implemented PlatformPrintJobController.onComplete" [#2216](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2216) (thanks to [Doflatango](https://github.com/Doflatango))
+
+#### macOS and iOS Platforms
+- Implemented `saveState`, `restoreState` InAppWebViewController methods
+- Implemented `PlatformProxyController` class
+- Merged "Add proxy support for iOS" [#2362](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2362) (thanks to [yerkejs](https://github.com/yerkejs))
+- Fixed "[iOS] Webview opened with windowId does not receive javascript handler callback." [#2393](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2393)
+- Fixed internal javascript callback handlers when the WebView has windowId not null
+- macos: Fixed crash of unhandled `onPrintRequest` WebView event
+
+### Windows
+- Merged "windows: fix WebViewEnvironment dispose crash" [#2433](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2433) (thanks to [GooRingX](https://github.com/GooRingX))
+
+## 6.2.0-beta.2
+
+- Updated dependencies to the latest versions for all platform implementations:
+ - `flutter_inappwebview_platform_interface`: `^1.4.0-beta.1` -> `^1.4.0-beta.2`
+ - `flutter_inappwebview_android`: `^1.2.0-beta.1` -> `^1.2.0-beta.2`
+ - `flutter_inappwebview_ios`: `^1.2.0-beta.1` -> `^1.2.0-beta.2`
+ - `flutter_inappwebview_macos`: `^1.2.0-beta.1` -> `^1.2.0-beta.2`
+ - `flutter_inappwebview_web`: `^1.2.0-beta.1` -> `^1.2.0-beta.2`
+ - `flutter_inappwebview_windows`: `^0.7.0-beta.1` -> `^0.7.0-beta.2`
+- Fixed specific URLAuthenticationChallenge type for `onReceivedHttpAuthRequest`, `onReceivedServerTrustAuthRequest`, `onReceivedClientCertRequest` events of HeadlessInAppWebView
+- Fixed missing return type for `InAppWebViewController.getJavaScriptBridgeName` static method
+
+#### Platform Interface
+- Updated `flutter_inappwebview_internal_annotations` dependency from `^1.1.1` to `^1.2.0`
+- Updated `fromMap` static method and `toMap` method implementations
+- Updated all WebView events with return type `Future` to type `FutureOr` in order to not force the usage of `async` keyword
+- Added `byName`, `name`, `asNameMap` custom enum classes methods
+- Added `statusBarEnabled`, `browserAcceleratorKeysEnabled`, `generalAutofillEnabled`, `passwordAutosaveEnabled`, `isPinchZoomEnabled`, `hiddenPdfToolbarItems`, `reputationCheckingRequired`, `nonClientRegionSupportEnabled`, `alpha`, `isUserInteractionEnabled` properties to `InAppWebViewSettings`
+- Added `isInterfaceSupported`, `getProcessInfos`, `getFailureReportFolderPath` methods to `PlatformWebViewEnvironment` class
+- Added `isInterfaceSupported`, `setInputMethodEnabled`, `hideInputMethod`, `showInputMethod` methods to `PlatformInAppWebViewController` class
+- Added `exclusiveUserDataFolderAccess`, `isCustomCrashReportingEnabled`, `enableTrackingPrevention`, `areBrowserExtensionsEnabled`, `channelSearchKind`, `releaseChannels`, `scrollbarStyle` properties to `WebViewEnvironmentSettings`
+- Added `onDownloadStarting` WebView event and deprecated `onDownloadStartRequest` event
+- Added `onNewBrowserVersionAvailable`, `onBrowserProcessExited`, `onProcessInfosChanged` events to `PlatformWebViewEnvironment` class
+- Fixed missing PrintJobOrientation android values
+
+#### Android Platform
+- Implemented `hideInputMethod`, `showInputMethod` InAppWebViewController methods
+- Implemented `isUserInteractionEnabled`, `alpha` properties of `InAppWebViewSettings`
+- Merged "Show / Hide / Disable / Enable soft Keyboard Input (Android & iOS)" [#2408](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2408) (thanks to [Mecharyry](https://github.com/Mecharyry))
+- Fixed "[Android] PrintJobOrientation _TypeError (type 'Null' is not a subtype of type 'int')" [#2413](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2413)
+- Fixed "Accessibility Android" [#1694](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1694)
+- Fixed "Automatic font scale according to accessibility option 'font size' of device does not work on Android" [#540](https://github.com/pichillilorenzo/flutter_inappwebview/issues/540)
+- Fixed "callHandler method is not injected into InAppBrowser" [#1973](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1973)
+
+#### iOS Platform
+- Implemented `setInputMethodEnabled`, `hideInputMethod` InAppWebViewController methods
+- Implemented `isUserInteractionEnabled`, `alpha` properties of `InAppWebViewSettings`
+- Merged "Show / Hide / Disable / Enable soft Keyboard Input (Android & iOS)" [#2408](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2408) (thanks to [Mecharyry](https://github.com/Mecharyry))
+- Fixed "In iOS version 17.2, when moving the input focus in a WebView, an unknown area appears at the top of the screen." [#1947](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1947)
+
+#### macOS Platform
+- Implemented `alpha` property of `InAppWebViewSettings`
+
+#### Windows Platform
+- Updated Microsoft.Web.WebView2 SDK version from `1.0.2792.45` to `1.0.2849.39`
+- Implemented `disableDefaultErrorPage`, `statusBarEnabled`, `browserAcceleratorKeysEnabled`, `generalAutofillEnabled`, `passwordAutosaveEnabled`, `isPinchZoomEnabled`, `allowsBackForwardNavigationGestures`, `hiddenPdfToolbarItems`, `reputationCheckingRequired`, `nonClientRegionSupportEnabled` properties of `InAppWebViewSettings`
+- Implemented `isInterfaceSupported`, `getProcessInfos`, `getFailureReportFolderPath` WebViewEnvironment methods
+- Implemented `isInterfaceSupported`, `getZoomScale` InAppWebViewController method
+- Implemented `onDownloadStarting`, `onAcceleratorKeyPressed` WebView event
+- Implemented `exclusiveUserDataFolderAccess`, `isCustomCrashReportingEnabled`, `enableTrackingPrevention`, `areBrowserExtensionsEnabled`, `channelSearchKind`, `releaseChannels`, `scrollbarStyle` properties of `WebViewEnvironmentSettings`
+- Implemented `onNewBrowserVersionAvailable`, `onBrowserProcessExited`, `onProcessInfosChanged` WebViewEnvironment events
+- Send mouse leave region event to native view
+- Fixed wrong channel name when creating a `WebViewEnvironment` instance
+- Fixed "[Windows] Has an overlay on the desktop when the application is minimized" [#2402](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2402)
+- Fixed "[Windows] missing implementation of onPermissionRequest event will cause crash when requested by the webpage" [#2404](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2404)
+- Fixed "Windows: getCookies return empty list" [#2314](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2314)
+
+## 6.2.0-beta.1
+
+- Updated dependencies to the latest versions for all platform implementations:
+ - `flutter_inappwebview_platform_interface`: `^1.3.0` -> `^1.4.0-beta.1`
+ - `flutter_inappwebview_android`: `^1.1.3` -> `^1.2.0-beta.1`
+ - `flutter_inappwebview_ios`: `^1.1.2` -> `^1.2.0-beta.1`
+ - `flutter_inappwebview_macos`: `^1.1.2` -> `^1.2.0-beta.1`
+ - `flutter_inappwebview_web`: `^1.1.2` -> `^1.2.0-beta.1`
+ - `flutter_inappwebview_windows`: `^0.6.0` -> `^0.7.0-beta.1`
+- Fixed specific URLAuthenticationChallenge type for `onReceivedHttpAuthRequest`, `onReceivedServerTrustAuthRequest`, `onReceivedClientCertRequest` events
+
+Implemented security features to better manage access to the native javascript bridge.
+
+#### Platform Interface
+- Updated static `fromMap` implementation for some classes
+- Updated `kJavaScriptHandlerForbiddenNames` list
+- Added `PlatformInAppLocalhostServer.onData` parameter to set a custom on data server callback
+- Added `javaScriptBridgeEnabled`, `javaScriptBridgeOriginAllowList`, `javaScriptBridgeForMainFrameOnly`, `pluginScriptsOriginAllowList`, `pluginScriptsForMainFrameOnly`, `javaScriptHandlersOriginAllowList`, `javaScriptHandlersForMainFrameOnly`, `scrollMultiplier` InAppWebViewSettings parameters
+- Added `setJavaScriptBridgeName`, `getJavaScriptBridgeName` static WebView controller methods
+- Added `requestFocus` WebView method
+- Added `onProcessFailed` WebView event
+- Added `regexToAllowSyncUrlLoading` Android-specific property to `InAppWebViewSettings`
+- Added `JavaScriptHandlerFunctionData` type
+- Deprecated `JavaScriptHandlerCallback` type in favor of `JavaScriptHandlerFunction` type
+- Deprecated `InAppWebViewSettings.forceDark` and `InAppWebViewSettings.forceDarkStrategy` Android-only properties in favor of `InAppWebViewSettings.algorithmicDarkeningAllowed`
+- Fixed X509Certificate PEM base64 decoding
+
+#### Android Platform
+- Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method
+- Added `CookieManager.flush` method
+- Added support for `UserScript.forMainFrameOnly` parameter
+- Implemented `requestFocus` WebView method
+- Updated UserScript at document end implementation
+- Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called
+- Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025)
+- Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode
+- Fixed "android.webkit.WebSettingsWrapper cannot be cast to com.android.webview.chromium.ContentSettingsAdapter" [#2397](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2397)
+- Merged "Prevent blank InAppBrowser Activity from being restored" [#1984](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1984) (thanks to [ShuheiSuzuki-07](https://github.com/ShuheiSuzuki-07))
+- Merged "Update Android Cookie Expiration date format to 24-hour format (HH)" [#2389](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2389) (thanks to [takuyaaaaaaahaaaaaa](https://github.com/takuyaaaaaaahaaaaaa))
+- Merged "[Android] allow sync navigation requests using a regular expression" [#2008](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2008) (thanks to [lyb5834](https://github.com/lyb5834))
+
+#### macOS and iOS Platforms
+- Implemented `requestFocus` WebView method
+- Updated ConsoleLogJS internal PluginScript to main-frame only as using it on non-main frames could cause issues such as [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738)
+- Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error
+- Added support for `UserScript.allowedOriginRules` parameter
+- Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog))
+- ios: Fixed `show`, `hide` methods and `hidden` setting for `InAppBrowser`
+- macOS: Implemented also `clearFocus` WebView method
+- macOS: Implemented workaround for "[macOS] Copy Shortcut does not work if TextField outside of WebView has focus" [#2380](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2380)
+
+#### Windows Platform
+- Updated `scrollMultiplier` default value from 6 to 1
+- Added support for `UserScript.allowedOriginRules` and `UserScript.forMainFrameOnly` parameters
+- Implemented `onReceivedHttpAuthRequest`, `onReceivedClientCertRequest`, `onReceivedServerTrustAuthRequest`, `onRenderProcessGone`, `onRenderProcessUnresponsive`, `onWebContentProcessDidTerminate`, `onProcessFailed` WebView events
+- Implemented `clearSslPreferences` WebView method
+- Fixed `get_optional_fl_map_value` implementation in `utils/flutter.h`
+- Fixed "Error in transparentBackground handling in Windows" [#2391](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2391)
+
+#### Web Platform
+- Merged "[web] support iframe role and aria-hidden attributes" [2293](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2293) (thanks to [p-mazhnik](https://github.com/p-mazhnik))
+- Fixed 'Type 'int' is not a subtype of type 'JSValue' in type cast' when compiling/running using WASM
+
+## 6.1.5
+
+- Updated dependencies to the latest versions for all platform implementations:
+ - `flutter_inappwebview_windows`: `^0.5.0` -> `^0.6.0`
+
+#### Windows Platform
+- Updated code to support multiple flutter windows
+- Fixed `InAppWebViewController.callAsyncJavaScript` not working with JSON objects
+- Fixed `onLoadResourceWithCustomScheme` WebView event called every time
+
## 6.1.4
- Updated dependencies to the latest versions for all platform implementations:
diff --git a/flutter_inappwebview/README.md b/flutter_inappwebview/README.md
index fe2d03493..6d63860ad 100755
--- a/flutter_inappwebview/README.md
+++ b/flutter_inappwebview/README.md
@@ -5,7 +5,7 @@

-[](#contributors-)
+[](#contributors-)
[](https://pub.dartlang.org/packages/flutter_inappwebview)
@@ -191,6 +191,21 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 Gray Mackall 💻 |
 Pavel Mazhnik 💻 |
+
+  nlog (solrin) 💻 |
+  Murmurl912 💻 |
+  Benjamin Schulz 🤔 |
+  seal-app 💻 |
+  Takuya Tominaga 💻 |
+  Sergey 💻 |
+  yuanbo li 💻 |
+
+
+  Ryan Feline 💻 |
+  Jeff Ward ⚠️ |
+  Yelzhan Yerkebulan 💻 |
+  GooRingX 💻 |
+
diff --git a/flutter_inappwebview/example/android/app/build.gradle b/flutter_inappwebview/example/android/app/build.gradle
index 50bdc4636..a50a94003 100755
--- a/flutter_inappwebview/example/android/app/build.gradle
+++ b/flutter_inappwebview/example/android/app/build.gradle
@@ -45,6 +45,10 @@ android {
buildTypes {
release {
+ // only for com.pichillilorenzo.flutter_inappwebview_android.R.menu.menu_main
+ minifyEnabled false
+ shrinkResources false
+
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
diff --git a/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart b/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart
index 4615f4573..78eb9c4dc 100644
--- a/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart
+++ b/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart
@@ -40,7 +40,7 @@ void openAndClose() {
activityButton: ActivityButton(
templateImage: UIImage(systemName: "sun.max"),
extensionIdentifier:
- "com.pichillilorenzo.flutterinappwebview-ios-example.test")));
+ "com.pichillilorenzo.flutterinappwebview-ios-example3.test")));
await chromeSafariBrowser.opened.future;
expect(chromeSafariBrowser.isOpened(), true);
expect(() async {
diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/main.dart b/flutter_inappwebview/example/integration_test/in_app_webview/main.dart
index 6f9239dbb..4f2b9a863 100644
--- a/flutter_inappwebview/example/integration_test/in_app_webview/main.dart
+++ b/flutter_inappwebview/example/integration_test/in_app_webview/main.dart
@@ -220,7 +220,7 @@ void main() {
contentBlocker();
httpAuthCredentialDatabase();
onConsoleMessage();
- onDownloadStartRequest();
+ onDownloadStarting();
javascriptDialogs();
onReceivedHttpError();
onLoadResourceWithCustomScheme();
diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/on_download_start_request.dart b/flutter_inappwebview/example/integration_test/in_app_webview/on_download_start_request.dart
index ba735534d..952c0d0e7 100644
--- a/flutter_inappwebview/example/integration_test/in_app_webview/on_download_start_request.dart
+++ b/flutter_inappwebview/example/integration_test/in_app_webview/on_download_start_request.dart
@@ -1,6 +1,6 @@
part of 'main.dart';
-void onDownloadStartRequest() {
+void onDownloadStarting() {
final shouldSkip = kIsWeb
? true
: ![
@@ -9,7 +9,7 @@ void onDownloadStartRequest() {
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
- skippableTestWidgets('onDownloadStartRequest', (WidgetTester tester) async {
+ skippableTestWidgets('onDownloadStarting', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer();
final Completer onDownloadStartCompleter = Completer();
@@ -41,8 +41,9 @@ void onDownloadStartRequest() {
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
- onDownloadStartRequest: (controller, request) {
+ onDownloadStarting: (controller, request) {
onDownloadStartCompleter.complete(request.url.toString());
+ return null;
},
),
),
diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart b/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart
index 078218caf..933bfc428 100644
--- a/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart
+++ b/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart
@@ -32,10 +32,14 @@ void userScripts() {
UserScript(
source: "var bar = 2;",
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END,
+ forMainFrameOnly:
+ defaultTargetPlatform != TargetPlatform.android,
contentWorld: ContentWorld.DEFAULT_CLIENT),
UserScript(
source: "var bar2 = 12;",
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END,
+ forMainFrameOnly:
+ defaultTargetPlatform != TargetPlatform.android,
contentWorld: ContentWorld.world(name: "test")),
]),
onWebViewCreated: (controller) {
diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart b/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart
index 914011ec4..36a25f410 100644
--- a/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart
+++ b/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart
@@ -60,7 +60,9 @@ void webArchive() {
controllerCompleter.complete(controller);
},
onLoadStop: (controller, url) {
- pageLoaded.complete();
+ if (!pageLoaded.isCompleted) {
+ pageLoaded.complete();
+ }
},
),
),
diff --git a/flutter_inappwebview/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart b/flutter_inappwebview/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart
index 349902e6f..8a8a4392c 100644
--- a/flutter_inappwebview/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart
+++ b/flutter_inappwebview/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart
@@ -5,6 +5,8 @@ void clearAndSetProxyOverride() {
? true
: ![
TargetPlatform.android,
+ TargetPlatform.iOS,
+ TargetPlatform.macOS,
].contains(defaultTargetPlatform);
skippableTestWidgets('clear and set proxy override',
@@ -13,7 +15,7 @@ void clearAndSetProxyOverride() {
Completer();
final Completer pageLoaded = Completer();
- var proxyAvailable =
+ var proxyAvailable = defaultTargetPlatform != TargetPlatform.android ||
await WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE);
if (proxyAvailable) {
diff --git a/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj b/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj
index 6e356e166..2e0efe407 100644
--- a/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj
@@ -481,7 +481,7 @@
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
- PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2.test";
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example4.test";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
@@ -518,7 +518,7 @@
);
MARKETING_VERSION = 1.0;
MTL_FAST_MATH = YES;
- PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2.test";
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example4.test";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -667,7 +667,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
- PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2";
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example4";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -702,7 +702,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
- PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2";
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example4";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
diff --git a/flutter_inappwebview/example/lib/headless_in_app_webview.screen.dart b/flutter_inappwebview/example/lib/headless_in_app_webview.screen.dart
index 5bfa5db18..67a8f88c7 100755
--- a/flutter_inappwebview/example/lib/headless_in_app_webview.screen.dart
+++ b/flutter_inappwebview/example/lib/headless_in_app_webview.screen.dart
@@ -35,12 +35,12 @@ class _HeadlessInAppWebViewExampleScreenState
onConsoleMessage: (controller, consoleMessage) {
print("CONSOLE MESSAGE: " + consoleMessage.message);
},
- onLoadStart: (controller, url) async {
+ onLoadStart: (controller, url) {
setState(() {
this.url = url.toString();
});
},
- onLoadStop: (controller, url) async {
+ onLoadStop: (controller, url) {
setState(() {
this.url = url.toString();
});
diff --git a/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart b/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart
index f0870a903..73f893358 100755
--- a/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart
+++ b/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart
@@ -22,20 +22,20 @@ class MyInAppBrowser extends InAppBrowser {
);
@override
- Future onBrowserCreated() async {
+ void onBrowserCreated() {
print("\n\nBrowser Created!\n\n");
}
@override
- Future onLoadStart(url) async {}
+ void onLoadStart(url) {}
@override
- Future onLoadStop(url) async {
+ void onLoadStop(url) {
pullToRefreshController?.endRefreshing();
}
@override
- Future onPermissionRequest(request) async {
+ FutureOr onPermissionRequest(request) {
return PermissionResponse(
resources: request.resources, action: PermissionResponseAction.GRANT);
}
@@ -58,8 +58,8 @@ class MyInAppBrowser extends InAppBrowser {
}
@override
- Future shouldOverrideUrlLoading(
- navigationAction) async {
+ FutureOr shouldOverrideUrlLoading(
+ navigationAction) {
print("\n\nOverride ${navigationAction.request.url}\n\n");
return NavigationActionPolicy.ALLOW;
}
diff --git a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart
index ce3dbcfd5..4acc6d966 100755
--- a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart
+++ b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart
@@ -1,4 +1,5 @@
import 'dart:collection';
+
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
@@ -127,13 +128,13 @@ class _InAppWebViewExampleScreenState extends State {
onWebViewCreated: (controller) async {
webViewController = controller;
},
- onLoadStart: (controller, url) async {
+ onLoadStart: (controller, url) {
setState(() {
this.url = url.toString();
urlController.text = this.url;
});
},
- onPermissionRequest: (controller, request) async {
+ onPermissionRequest: (controller, request) {
return PermissionResponse(
resources: request.resources,
action: PermissionResponseAction.GRANT);
@@ -163,7 +164,7 @@ class _InAppWebViewExampleScreenState extends State {
return NavigationActionPolicy.ALLOW;
},
- onLoadStop: (controller, url) async {
+ onLoadStop: (controller, url) {
pullToRefreshController?.endRefreshing();
setState(() {
this.url = url.toString();
diff --git a/flutter_inappwebview/example/lib/main.dart b/flutter_inappwebview/example/lib/main.dart
index ebb77618f..0a7802bd8 100755
--- a/flutter_inappwebview/example/lib/main.dart
+++ b/flutter_inappwebview/example/lib/main.dart
@@ -3,11 +3,10 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
-
import 'package:flutter_inappwebview_example/chrome_safari_browser_example.screen.dart';
import 'package:flutter_inappwebview_example/headless_in_app_webview.screen.dart';
-import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart';
import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart';
+import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart';
import 'package:flutter_inappwebview_example/web_authentication_session_example.screen.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
@@ -29,7 +28,18 @@ Future main() async {
'Failed to find an installed WebView2 runtime or non-stable Microsoft Edge installation.');
webViewEnvironment = await WebViewEnvironment.create(
- settings: WebViewEnvironmentSettings(userDataFolder: 'custom_path'));
+ settings: WebViewEnvironmentSettings(
+ additionalBrowserArguments: kDebugMode
+ ? '--enable-features=msEdgeDevToolsWdpRemoteDebugging'
+ : null,
+ userDataFolder: 'custom_path',
+ ));
+
+ webViewEnvironment?.onBrowserProcessExited = (detail) {
+ if (kDebugMode) {
+ print('Browser process exited with detail: $detail');
+ }
+ };
}
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
diff --git a/flutter_inappwebview/example/macos/Runner/Info.plist b/flutter_inappwebview/example/macos/Runner/Info.plist
index 4789daa6a..0c93eff43 100644
--- a/flutter_inappwebview/example/macos/Runner/Info.plist
+++ b/flutter_inappwebview/example/macos/Runner/Info.plist
@@ -22,6 +22,13 @@
$(FLUTTER_BUILD_NUMBER)
LSMinimumSystemVersion
$(MACOSX_DEPLOYMENT_TARGET)
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+ NSAllowsArbitraryLoadsInWebContent
+
+
NSHumanReadableCopyright
$(PRODUCT_COPYRIGHT)
NSMainNibFile
diff --git a/flutter_inappwebview/example/test/widget_test.dart b/flutter_inappwebview/example/test/widget_test.dart
index 092d222f7..e69de29bb 100644
--- a/flutter_inappwebview/example/test/widget_test.dart
+++ b/flutter_inappwebview/example/test/widget_test.dart
@@ -1,30 +0,0 @@
-// 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);
- });
-}
diff --git a/flutter_inappwebview/example/windows/runner/win32_window.cpp b/flutter_inappwebview/example/windows/runner/win32_window.cpp
index 60608d0fe..786879fac 100644
--- a/flutter_inappwebview/example/windows/runner/win32_window.cpp
+++ b/flutter_inappwebview/example/windows/runner/win32_window.cpp
@@ -7,61 +7,64 @@
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
+ /// 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";
+ 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";
+ /// 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;
+ // The number of Win32Window objects that currently exist.
+ static int g_active_window_count = 0;
-using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
+ 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(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;
+ // Scale helper to convert logical scaler values to physical using passed in
+ // scale factor
+ int Scale(int source, double scale_factor)
+ {
+ return static_cast(source * scale_factor);
}
- auto enable_non_client_dpi_scaling =
+
+ // 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(
- GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
- if (enable_non_client_dpi_scaling != nullptr) {
- enable_non_client_dpi_scaling(hwnd);
+ GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
+ if (enable_non_client_dpi_scaling != nullptr) {
+ enable_non_client_dpi_scaling(hwnd);
+ }
+ FreeLibrary(user32_module);
}
- FreeLibrary(user32_module);
-}
} // namespace
// Manages the Win32Window's window class registration.
class WindowClassRegistrar {
- public:
+public:
~WindowClassRegistrar() = default;
// Returns the singleton registrar instance.
- static WindowClassRegistrar* GetInstance() {
+ static WindowClassRegistrar* GetInstance()
+ {
if (!instance_) {
instance_ = new WindowClassRegistrar();
}
@@ -76,7 +79,7 @@ class WindowClassRegistrar {
// instances of the window.
void UnregisterWindowClass();
- private:
+private:
WindowClassRegistrar() = default;
static WindowClassRegistrar* instance_;
@@ -86,7 +89,8 @@ class WindowClassRegistrar {
WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
-const wchar_t* WindowClassRegistrar::GetWindowClass() {
+const wchar_t* WindowClassRegistrar::GetWindowClass()
+{
if (!class_registered_) {
WNDCLASS window_class{};
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
@@ -96,7 +100,7 @@ const wchar_t* WindowClassRegistrar::GetWindowClass() {
window_class.cbWndExtra = 0;
window_class.hInstance = GetModuleHandle(nullptr);
window_class.hIcon =
- LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
+ LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
window_class.hbrBackground = 0;
window_class.lpszMenuName = nullptr;
window_class.lpfnWndProc = Win32Window::WndProc;
@@ -106,39 +110,43 @@ const wchar_t* WindowClassRegistrar::GetWindowClass() {
return kWindowClassName;
}
-void WindowClassRegistrar::UnregisterWindowClass() {
+void WindowClassRegistrar::UnregisterWindowClass()
+{
UnregisterClass(kWindowClassName, nullptr);
class_registered_ = false;
}
-Win32Window::Win32Window() {
+Win32Window::Win32Window()
+{
++g_active_window_count;
}
-Win32Window::~Win32Window() {
+Win32Window::~Win32Window()
+{
--g_active_window_count;
Destroy();
}
bool Win32Window::Create(const std::wstring& title,
- const Point& origin,
- const Size& size) {
+ const Point& origin,
+ const Size& size)
+{
Destroy();
const wchar_t* window_class =
- WindowClassRegistrar::GetInstance()->GetWindowClass();
+ WindowClassRegistrar::GetInstance()->GetWindowClass();
- const POINT target_point = {static_cast(origin.x),
- static_cast(origin.y)};
+ const POINT target_point = { static_cast(origin.x),
+ static_cast(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);
+ 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;
@@ -149,24 +157,27 @@ bool Win32Window::Create(const std::wstring& title,
return OnCreate();
}
-bool Win32Window::Show() {
+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 {
+ UINT const message,
+ WPARAM const wparam,
+ LPARAM const lparam) noexcept
+{
if (message == WM_NCCREATE) {
auto window_struct = reinterpret_cast(lparam);
SetWindowLongPtr(window, GWLP_USERDATA,
- reinterpret_cast(window_struct->lpCreateParams));
+ reinterpret_cast(window_struct->lpCreateParams));
auto that = static_cast(window_struct->lpCreateParams);
EnableFullDpiSupportIfAvailable(window);
that->window_handle_ = window;
- } else if (Win32Window* that = GetThisFromHandle(window)) {
+ }
+ else if (Win32Window* that = GetThisFromHandle(window)) {
return that->MessageHandler(window, message, wparam, lparam);
}
@@ -175,53 +186,55 @@ LRESULT CALLBACK Win32Window::WndProc(HWND const window,
LRESULT
Win32Window::MessageHandler(HWND hwnd,
- UINT const message,
- WPARAM const wparam,
- LPARAM const lparam) noexcept {
+ 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(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_DESTROY:
+ window_handle_ = nullptr;
+ Destroy();
+ if (quit_on_close_) {
+ PostQuitMessage(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;
+ return 0;
+
+ case WM_DPICHANGED: {
+ auto newRectSize = reinterpret_cast(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_ACTIVATE:
+ if (child_content_ != nullptr) {
+ SetFocus(child_content_);
+ }
+ return 0;
- case WM_DWMCOLORIZATIONCOLORCHANGED:
- UpdateTheme(hwnd);
- return 0;
+ case WM_DWMCOLORIZATIONCOLORCHANGED:
+ UpdateTheme(hwnd);
+ return 0;
}
return DefWindowProc(window_handle_, message, wparam, lparam);
}
-void Win32Window::Destroy() {
+void Win32Window::Destroy()
+{
OnDestroy();
if (window_handle_) {
@@ -233,56 +246,64 @@ void Win32Window::Destroy() {
}
}
-Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
+Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept
+{
return reinterpret_cast(
- GetWindowLongPtr(window, GWLP_USERDATA));
+ GetWindowLongPtr(window, GWLP_USERDATA));
}
-void Win32Window::SetChildContent(HWND content) {
+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);
+ frame.bottom - frame.top, true);
SetFocus(child_content_);
}
-RECT Win32Window::GetClientArea() {
+RECT Win32Window::GetClientArea()
+{
RECT frame;
GetClientRect(window_handle_, &frame);
return frame;
}
-HWND Win32Window::GetHandle() {
+HWND Win32Window::GetHandle()
+{
return window_handle_;
}
-void Win32Window::SetQuitOnClose(bool quit_on_close) {
+void Win32Window::SetQuitOnClose(bool quit_on_close)
+{
quit_on_close_ = quit_on_close;
}
-bool Win32Window::OnCreate() {
+bool Win32Window::OnCreate()
+{
// No-op; provided for subclasses.
return true;
}
-void Win32Window::OnDestroy() {
+void Win32Window::OnDestroy()
+{
// No-op; provided for subclasses.
}
-void Win32Window::UpdateTheme(HWND const window) {
+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);
+ 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));
+ &enable_dark_mode, sizeof(enable_dark_mode));
}
}
diff --git a/flutter_inappwebview/lib/src/cookie_manager.dart b/flutter_inappwebview/lib/src/cookie_manager.dart
index 3ab49df1e..bebf0f303 100755
--- a/flutter_inappwebview/lib/src/cookie_manager.dart
+++ b/flutter_inappwebview/lib/src/cookie_manager.dart
@@ -143,6 +143,9 @@ class CookieManager {
///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.removeSessionCookies}
Future removeSessionCookies() => platform.removeSessionCookies();
+
+ ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.flush}
+ Future flush() => platform.flush();
}
///Class that contains only iOS-specific methods of [CookieManager].
diff --git a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart
index 3c0d8ca73..dbaeb6d63 100755
--- a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart
+++ b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart
@@ -199,96 +199,133 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
@mustCallSuper
void dispose() => platform.dispose();
+ ///Use [onFormResubmission] instead.
+ @Deprecated('Use onFormResubmission instead')
@override
- Future? androidOnFormResubmission(Uri? url) {
+ FutureOr? androidOnFormResubmission(Uri? url) {
return null;
}
+ ///Use [onGeolocationPermissionsHidePrompt] instead.
+ @Deprecated("Use onGeolocationPermissionsHidePrompt instead")
@override
void androidOnGeolocationPermissionsHidePrompt() {}
+ ///Use [onGeolocationPermissionsShowPrompt] instead.
+ @Deprecated("Use onGeolocationPermissionsShowPrompt instead")
@override
- Future?
+ FutureOr?
androidOnGeolocationPermissionsShowPrompt(String origin) {
return null;
}
+ ///Use [onJsBeforeUnload] instead.
+ @Deprecated('Use onJsBeforeUnload instead')
@override
- Future? androidOnJsBeforeUnload(
+ FutureOr? androidOnJsBeforeUnload(
JsBeforeUnloadRequest jsBeforeUnloadRequest) {
return null;
}
+ ///Use [onPermissionRequest] instead.
+ @Deprecated("Use onPermissionRequest instead")
@override
- Future? androidOnPermissionRequest(
+ FutureOr? androidOnPermissionRequest(
String origin, List resources) {
return null;
}
+ ///Use [onReceivedIcon] instead.
+ @Deprecated('Use onReceivedIcon instead')
@override
void androidOnReceivedIcon(Uint8List icon) {}
+ ///Use [onReceivedLoginRequest] instead.
+ @Deprecated('Use onReceivedLoginRequest instead')
@override
void androidOnReceivedLoginRequest(LoginRequest loginRequest) {}
+ ///Use [onReceivedTouchIconUrl] instead.
+ @Deprecated('Use onReceivedTouchIconUrl instead')
@override
void androidOnReceivedTouchIconUrl(Uri url, bool precomposed) {}
+ ///Use [onRenderProcessGone] instead.
+ @Deprecated("Use onRenderProcessGone instead")
@override
void androidOnRenderProcessGone(RenderProcessGoneDetail detail) {}
+ ///Use [onRenderProcessResponsive] instead.
+ @Deprecated("Use onRenderProcessResponsive instead")
@override
- Future? androidOnRenderProcessResponsive(
+ FutureOr? androidOnRenderProcessResponsive(
Uri? url) {
return null;
}
+ ///Use [onRenderProcessUnresponsive] instead.
+ @Deprecated("Use onRenderProcessUnresponsive instead")
@override
- Future? androidOnRenderProcessUnresponsive(
+ FutureOr? androidOnRenderProcessUnresponsive(
Uri? url) {
return null;
}
+ ///Use [onSafeBrowsingHit] instead.
+ @Deprecated("Use onSafeBrowsingHit instead")
@override
- Future? androidOnSafeBrowsingHit(
+ FutureOr? androidOnSafeBrowsingHit(
Uri url, SafeBrowsingThreat? threatType) {
return null;
}
+ ///Use [onZoomScaleChanged] instead.
+ @Deprecated('Use onZoomScaleChanged instead')
@override
void androidOnScaleChanged(double oldScale, double newScale) {}
+ ///Use [shouldInterceptRequest] instead.
+ @Deprecated("Use shouldInterceptRequest instead")
@override
- Future? androidShouldInterceptRequest(
+ FutureOr? androidShouldInterceptRequest(
WebResourceRequest request) {
return null;
}
+ ///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead.
+ @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
@override
void iosOnDidReceiveServerRedirectForProvisionalNavigation() {}
+ ///Use [onNavigationResponse] instead.
+ @Deprecated('Use onNavigationResponse instead')
@override
- Future? iosOnNavigationResponse(
+ FutureOr? iosOnNavigationResponse(
IOSWKNavigationResponse navigationResponse) {
return null;
}
+ ///Use [onWebContentProcessDidTerminate] instead.
+ @Deprecated('Use onWebContentProcessDidTerminate instead')
@override
void iosOnWebContentProcessDidTerminate() {}
+ ///Use [shouldAllowDeprecatedTLS] instead.
+ @Deprecated('Use shouldAllowDeprecatedTLS instead')
@override
- Future? iosShouldAllowDeprecatedTLS(
+ FutureOr? iosShouldAllowDeprecatedTLS(
URLAuthenticationChallenge challenge) {
return null;
}
@override
- Future? onAjaxProgress(AjaxRequest ajaxRequest) {
+ FutureOr? onAjaxProgress(AjaxRequest ajaxRequest) {
return null;
}
@override
- Future? onAjaxReadyStateChange(AjaxRequest ajaxRequest) {
+ FutureOr? onAjaxReadyStateChange(
+ AjaxRequest ajaxRequest) {
return null;
}
@@ -309,19 +346,29 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onContentSizeChanged(Size oldContentSize, Size newContentSize) {}
@override
- Future? onCreateWindow(CreateWindowAction createWindowAction) {
+ FutureOr? onCreateWindow(CreateWindowAction createWindowAction) {
return null;
}
@override
void onDidReceiveServerRedirectForProvisionalNavigation() {}
+ ///Use [onDownloadStarting] instead
+ @Deprecated('Use onDownloadStarting instead')
@override
void onDownloadStart(Uri url) {}
+ ///Use [onDownloadStarting] instead
+ @Deprecated('Use onDownloadStarting instead')
@override
void onDownloadStartRequest(DownloadStartRequest downloadStartRequest) {}
+ @override
+ FutureOr? onDownloadStarting(
+ DownloadStartRequest downloadStartRequest) {
+ return null;
+ }
+
@override
void onEnterFullscreen() {}
@@ -331,12 +378,14 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
@override
void onExitFullscreen() {}
+ ///Use [FindInteractionController.onFindResultReceived] instead.
+ @Deprecated('Use FindInteractionController.onFindResultReceived instead')
@override
void onFindResultReceived(
int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) {}
@override
- Future? onFormResubmission(WebUri? url) {
+ FutureOr? onFormResubmission(WebUri? url) {
return null;
}
@@ -344,48 +393,54 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onGeolocationPermissionsHidePrompt() {}
@override
- Future?
+ FutureOr?
onGeolocationPermissionsShowPrompt(String origin) {
return null;
}
@override
- Future? onJsAlert(JsAlertRequest jsAlertRequest) {
+ FutureOr? onJsAlert(JsAlertRequest jsAlertRequest) {
return null;
}
@override
- Future? onJsBeforeUnload(
+ FutureOr? onJsBeforeUnload(
JsBeforeUnloadRequest jsBeforeUnloadRequest) {
return null;
}
@override
- Future? onJsConfirm(JsConfirmRequest jsConfirmRequest) {
+ FutureOr? onJsConfirm(JsConfirmRequest jsConfirmRequest) {
return null;
}
@override
- Future? onJsPrompt(JsPromptRequest jsPromptRequest) {
+ FutureOr? onJsPrompt(JsPromptRequest jsPromptRequest) {
return null;
}
+ ///Use [onReceivedError] instead.
+ @Deprecated("Use onReceivedError instead")
@override
void onLoadError(Uri? url, int code, String message) {}
+ ///Use [onReceivedHttpError] instead.
+ @Deprecated("Use onReceivedHttpError instead")
@override
void onLoadHttpError(Uri? url, int statusCode, String description) {}
@override
void onLoadResource(LoadedResource resource) {}
+ ///Use [onLoadResourceWithCustomScheme] instead.
+ @Deprecated('Use onLoadResourceWithCustomScheme instead')
@override
- Future? onLoadResourceCustomScheme(Uri url) {
+ FutureOr? onLoadResourceCustomScheme(Uri url) {
return null;
}
@override
- Future? onLoadResourceWithCustomScheme(
+ FutureOr? onLoadResourceWithCustomScheme(
WebResourceRequest request) {
return null;
}
@@ -404,7 +459,7 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
MediaCaptureState? oldState, MediaCaptureState? newState) {}
@override
- Future? onNavigationResponse(
+ FutureOr? onNavigationResponse(
NavigationResponse navigationResponse) {
return null;
}
@@ -416,7 +471,7 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onPageCommitVisible(WebUri? url) {}
@override
- Future? onPermissionRequest(
+ FutureOr? onPermissionRequest(
PermissionRequest permissionRequest) {
return null;
}
@@ -424,11 +479,13 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
@override
void onPermissionRequestCanceled(PermissionRequest permissionRequest) {}
+ ///Use [onPrintRequest] instead
+ @Deprecated("Use onPrintRequest instead")
@override
void onPrint(Uri? url) {}
@override
- Future? onPrintRequest(
+ FutureOr? onPrintRequest(
WebUri? url, PlatformPrintJobController? printJobController) {
return null;
}
@@ -437,8 +494,8 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onProgressChanged(int progress) {}
@override
- Future? onReceivedClientCertRequest(
- URLAuthenticationChallenge challenge) {
+ FutureOr? onReceivedClientCertRequest(
+ ClientCertChallenge challenge) {
return null;
}
@@ -446,8 +503,8 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onReceivedError(WebResourceRequest request, WebResourceError error) {}
@override
- Future? onReceivedHttpAuthRequest(
- URLAuthenticationChallenge challenge) {
+ FutureOr? onReceivedHttpAuthRequest(
+ HttpAuthenticationChallenge challenge) {
return null;
}
@@ -462,8 +519,8 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onReceivedLoginRequest(LoginRequest loginRequest) {}
@override
- Future? onReceivedServerTrustAuthRequest(
- URLAuthenticationChallenge challenge) {
+ FutureOr? onReceivedServerTrustAuthRequest(
+ ServerTrustChallenge challenge) {
return null;
}
@@ -474,12 +531,13 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onRenderProcessGone(RenderProcessGoneDetail detail) {}
@override
- Future? onRenderProcessResponsive(WebUri? url) {
+ FutureOr? onRenderProcessResponsive(
+ WebUri? url) {
return null;
}
@override
- Future? onRenderProcessUnresponsive(
+ FutureOr? onRenderProcessUnresponsive(
WebUri? url) {
return null;
}
@@ -488,7 +546,7 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onRequestFocus() {}
@override
- Future? onSafeBrowsingHit(
+ FutureOr? onSafeBrowsingHit(
WebUri url, SafeBrowsingThreat? threatType) {
return null;
}
@@ -515,34 +573,45 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
void onZoomScaleChanged(double oldScale, double newScale) {}
@override
- Future? shouldAllowDeprecatedTLS(
+ FutureOr? shouldAllowDeprecatedTLS(
URLAuthenticationChallenge challenge) {
return null;
}
@override
- Future? shouldInterceptAjaxRequest(AjaxRequest ajaxRequest) {
+ FutureOr? shouldInterceptAjaxRequest(AjaxRequest ajaxRequest) {
return null;
}
@override
- Future? shouldInterceptFetchRequest(
+ FutureOr? shouldInterceptFetchRequest(
FetchRequest fetchRequest) {
return null;
}
@override
- Future? shouldInterceptRequest(
+ FutureOr? shouldInterceptRequest(
WebResourceRequest request) {
return null;
}
@override
- Future? shouldOverrideUrlLoading(
+ FutureOr? shouldOverrideUrlLoading(
NavigationAction navigationAction) {
return null;
}
@override
void onMainWindowWillClose() {}
+
+ @override
+ void onProcessFailed(ProcessFailedDetail detail) {}
+
+ @override
+ void onAcceleratorKeyPressed(AcceleratorKeyPressedDetail detail) {}
+
+ @override
+ FutureOr onShowFileChooser(ShowFileChooserRequest request) {
+ return null;
+ }
}
diff --git a/flutter_inappwebview/lib/src/in_app_localhost_server.dart b/flutter_inappwebview/lib/src/in_app_localhost_server.dart
index daae11b7b..841f0cc29 100755
--- a/flutter_inappwebview/lib/src/in_app_localhost_server.dart
+++ b/flutter_inappwebview/lib/src/in_app_localhost_server.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:io';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer}
@@ -9,12 +10,14 @@ class InAppLocalhostServer {
String directoryIndex = 'index.html',
String documentRoot = './',
bool shared = false,
+ Future Function(HttpRequest request)? onData,
}) : this.fromPlatformCreationParams(
PlatformInAppLocalhostServerCreationParams(
port: port,
directoryIndex: directoryIndex,
documentRoot: documentRoot,
- shared: shared),
+ shared: shared,
+ onData: onData),
);
/// Constructs a [InAppLocalhostServer] from creation params for a specific
@@ -42,6 +45,9 @@ class InAppLocalhostServer {
///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.shared}
bool get shared => platform.shared;
+ ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.onData}
+ Future Function(HttpRequest request)? get onData => platform.onData;
+
///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.start}
Future start() => platform.start();
diff --git a/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart
index f7c216624..252f3e5f8 100644
--- a/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart
+++ b/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart
@@ -1,13 +1,13 @@
+import 'dart:async';
import 'dart:collection';
-import 'dart:typed_data';
-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 '../pull_to_refresh/pull_to_refresh_controller.dart';
import '../webview_environment/webview_environment.dart';
import 'in_app_webview_controller.dart';
-import '../pull_to_refresh/pull_to_refresh_controller.dart';
///{@macro flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebView}
class HeadlessInAppWebView {
@@ -37,264 +37,139 @@ class HeadlessInAppWebView {
platform: webViewControllerPlatform);
}
- HeadlessInAppWebView({
- Size initialSize = const Size(-1, -1),
- int? windowId,
- HeadlessInAppWebView? headlessWebView,
- InAppWebViewKeepAlive? keepAlive,
- bool? preventGestureDelay,
- WebViewEnvironment? webViewEnvironment,
- @Deprecated('Use onGeolocationPermissionsHidePrompt instead')
- void Function(InAppWebViewController controller)?
- androidOnGeolocationPermissionsHidePrompt,
- @Deprecated('Use onGeolocationPermissionsShowPrompt instead')
- Future Function(
- InAppWebViewController controller, String origin)?
- androidOnGeolocationPermissionsShowPrompt,
- @Deprecated('Use onPermissionRequest instead')
- Future Function(
- InAppWebViewController controller,
- String origin,
- List resources)?
- androidOnPermissionRequest,
- @Deprecated('Use onSafeBrowsingHit instead')
- Future Function(InAppWebViewController controller,
- Uri url, SafeBrowsingThreat? threatType)?
- androidOnSafeBrowsingHit,
- InAppWebViewInitialData? initialData,
- String? initialFile,
- @Deprecated('Use initialSettings instead')
- InAppWebViewGroupOptions? initialOptions,
- InAppWebViewSettings? initialSettings,
- URLRequest? initialUrlRequest,
- UnmodifiableListView? initialUserScripts,
- PullToRefreshController? pullToRefreshController,
- FindInteractionController? findInteractionController,
- ContextMenu? contextMenu,
- void Function(InAppWebViewController controller, WebUri? url)?
- onPageCommitVisible,
- void Function(InAppWebViewController controller, String? title)?
- onTitleChanged,
- @Deprecated(
- 'Use onDidReceiveServerRedirectForProvisionalNavigation instead')
- void Function(InAppWebViewController controller)?
- iosOnDidReceiveServerRedirectForProvisionalNavigation,
- @Deprecated('Use onWebContentProcessDidTerminate instead')
- void Function(InAppWebViewController controller)?
- iosOnWebContentProcessDidTerminate,
- @Deprecated('Use onNavigationResponse instead')
- Future Function(
- InAppWebViewController controller,
- IOSWKNavigationResponse navigationResponse)?
- iosOnNavigationResponse,
- @Deprecated('Use shouldAllowDeprecatedTLS instead')
- Future Function(
- InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- iosShouldAllowDeprecatedTLS,
- Future Function(
- InAppWebViewController controller, AjaxRequest ajaxRequest)?
- onAjaxProgress,
- Future Function(
- InAppWebViewController controller, AjaxRequest ajaxRequest)?
- onAjaxReadyStateChange,
- void Function(
- InAppWebViewController controller, ConsoleMessage consoleMessage)?
- onConsoleMessage,
- Future Function(InAppWebViewController controller,
- CreateWindowAction createWindowAction)?
- onCreateWindow,
- void Function(InAppWebViewController controller)? onCloseWindow,
- void Function(InAppWebViewController controller)? onWindowFocus,
- void Function(InAppWebViewController controller)? onWindowBlur,
- @Deprecated('Use onReceivedIcon instead')
- void Function(InAppWebViewController controller, Uint8List icon)?
- androidOnReceivedIcon,
- @Deprecated('Use onReceivedTouchIconUrl instead')
- void Function(InAppWebViewController controller, Uri url, bool precomposed)?
- androidOnReceivedTouchIconUrl,
- @Deprecated('Use onDownloadStartRequest instead')
- void Function(InAppWebViewController controller, Uri url)? onDownloadStart,
- void Function(InAppWebViewController controller,
- DownloadStartRequest downloadStartRequest)?
- onDownloadStartRequest,
- @Deprecated('Use FindInteractionController.onFindResultReceived instead')
- void Function(InAppWebViewController controller, int activeMatchOrdinal,
- int numberOfMatches, bool isDoneCounting)?
- onFindResultReceived,
- Future Function(
- InAppWebViewController controller, JsAlertRequest jsAlertRequest)?
- onJsAlert,
- Future Function(InAppWebViewController controller,
- JsConfirmRequest jsConfirmRequest)?
- onJsConfirm,
- Future Function(
- InAppWebViewController controller, JsPromptRequest jsPromptRequest)?
- onJsPrompt,
- @Deprecated("Use onReceivedError instead")
- void Function(InAppWebViewController controller, Uri? url, int code,
- String message)?
- onLoadError,
- void Function(InAppWebViewController controller, WebResourceRequest request,
- WebResourceError error)?
- onReceivedError,
- @Deprecated("Use onReceivedHttpError instead")
- void Function(InAppWebViewController controller, Uri? url, int statusCode,
- String description)?
- onLoadHttpError,
- void Function(InAppWebViewController controller, WebResourceRequest request,
- WebResourceResponse errorResponse)?
- onReceivedHttpError,
- void Function(InAppWebViewController controller, LoadedResource resource)?
- onLoadResource,
- @Deprecated('Use onLoadResourceWithCustomScheme instead')
- Future Function(
- InAppWebViewController controller, Uri url)?
- onLoadResourceCustomScheme,
- Future Function(
- InAppWebViewController controller, WebResourceRequest request)?
- onLoadResourceWithCustomScheme,
- void Function(InAppWebViewController controller, WebUri? url)? onLoadStart,
- void Function(InAppWebViewController controller, WebUri? url)? onLoadStop,
- void Function(InAppWebViewController controller,
- InAppWebViewHitTestResult hitTestResult)?
- onLongPressHitTestResult,
- @Deprecated("Use onPrintRequest instead")
- void Function(InAppWebViewController controller, Uri? url)? onPrint,
- Future Function(InAppWebViewController controller, WebUri? url,
- PlatformPrintJobController? printJobController)?
- onPrintRequest,
- void Function(InAppWebViewController controller, int progress)?
- onProgressChanged,
- Future Function(InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- onReceivedClientCertRequest,
- Future Function(InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- onReceivedHttpAuthRequest,
- Future Function(InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- onReceivedServerTrustAuthRequest,
- void Function(InAppWebViewController controller, int x, int y)?
- onScrollChanged,
- void Function(
- InAppWebViewController controller, WebUri? url, bool? isReload)?
- onUpdateVisitedHistory,
- void Function(InAppWebViewController controller)? onWebViewCreated,
- Future Function(
- InAppWebViewController controller, AjaxRequest ajaxRequest)?
- shouldInterceptAjaxRequest,
- Future Function(
- InAppWebViewController controller, FetchRequest fetchRequest)?
- shouldInterceptFetchRequest,
- Future Function(InAppWebViewController controller,
- NavigationAction navigationAction)?
- shouldOverrideUrlLoading,
- void Function(InAppWebViewController controller)? onEnterFullscreen,
- void Function(InAppWebViewController controller)? onExitFullscreen,
- void Function(InAppWebViewController controller, int x, int y,
- bool clampedX, bool clampedY)?
- onOverScrolled,
- void Function(InAppWebViewController controller, double oldScale,
- double newScale)?
- onZoomScaleChanged,
- @Deprecated('Use shouldInterceptRequest instead')
- Future Function(
- InAppWebViewController controller, WebResourceRequest request)?
- androidShouldInterceptRequest,
- @Deprecated('Use onRenderProcessUnresponsive instead')
- Future Function(
- InAppWebViewController controller, Uri? url)?
- androidOnRenderProcessUnresponsive,
- @Deprecated('Use onRenderProcessResponsive instead')
- Future Function(
- InAppWebViewController controller, Uri? url)?
- androidOnRenderProcessResponsive,
- @Deprecated('Use onRenderProcessGone instead')
- void Function(
- InAppWebViewController controller, RenderProcessGoneDetail detail)?
- androidOnRenderProcessGone,
- @Deprecated('Use onFormResubmission instead')
- Future Function(
- InAppWebViewController controller, Uri? url)?
- androidOnFormResubmission,
- @Deprecated('Use onZoomScaleChanged instead')
- void Function(InAppWebViewController controller, double oldScale,
- double newScale)?
- androidOnScaleChanged,
- @Deprecated('Use onJsBeforeUnload instead')
- Future Function(InAppWebViewController controller,
- JsBeforeUnloadRequest jsBeforeUnloadRequest)?
- androidOnJsBeforeUnload,
- @Deprecated('Use onReceivedLoginRequest instead')
- void Function(InAppWebViewController controller, LoginRequest loginRequest)?
- androidOnReceivedLoginRequest,
- void Function(InAppWebViewController controller)?
- onDidReceiveServerRedirectForProvisionalNavigation,
- Future Function(
- InAppWebViewController controller, WebUri? url)?
- onFormResubmission,
- void Function(InAppWebViewController controller)?
- onGeolocationPermissionsHidePrompt,
- Future Function(
- InAppWebViewController controller, String origin)?
- onGeolocationPermissionsShowPrompt,
- Future Function(InAppWebViewController controller,
- JsBeforeUnloadRequest jsBeforeUnloadRequest)?
- onJsBeforeUnload,
- Future Function(
- InAppWebViewController controller,
- NavigationResponse navigationResponse)?
- onNavigationResponse,
- Future Function(InAppWebViewController controller,
- PermissionRequest permissionRequest)?
- onPermissionRequest,
- void Function(InAppWebViewController controller, Uint8List icon)?
- onReceivedIcon,
- void Function(InAppWebViewController controller, LoginRequest loginRequest)?
- onReceivedLoginRequest,
- void Function(InAppWebViewController controller,
- PermissionRequest permissionRequest)?
- onPermissionRequestCanceled,
- void Function(InAppWebViewController controller)? onRequestFocus,
- void Function(
- InAppWebViewController controller, WebUri url, bool precomposed)?
- onReceivedTouchIconUrl,
- void Function(
- InAppWebViewController controller, RenderProcessGoneDetail detail)?
- onRenderProcessGone,
- Future Function(
- InAppWebViewController controller, WebUri? url)?
- onRenderProcessResponsive,
- Future Function(
- InAppWebViewController controller, WebUri? url)?
- onRenderProcessUnresponsive,
- Future Function(InAppWebViewController controller,
- WebUri url, SafeBrowsingThreat? threatType)?
- onSafeBrowsingHit,
- void Function(InAppWebViewController controller)?
- onWebContentProcessDidTerminate,
- Future Function(
- InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- shouldAllowDeprecatedTLS,
- Future Function(
- InAppWebViewController controller, WebResourceRequest request)?
- shouldInterceptRequest,
- Future Function(
- InAppWebViewController controller,
- MediaCaptureState? oldState,
- MediaCaptureState? newState,
- )? onCameraCaptureStateChanged,
- Future Function(
- InAppWebViewController controller,
- MediaCaptureState? oldState,
- MediaCaptureState? newState,
- )? onMicrophoneCaptureStateChanged,
- void Function(InAppWebViewController controller, Size oldContentSize,
- Size newContentSize)?
- onContentSizeChanged,
- }) : this.fromPlatformCreationParams(
+ HeadlessInAppWebView(
+ {Size initialSize = const Size(-1, -1),
+ int? windowId,
+ HeadlessInAppWebView? headlessWebView,
+ InAppWebViewKeepAlive? keepAlive,
+ bool? preventGestureDelay,
+ WebViewEnvironment? webViewEnvironment,
+ @Deprecated('Use onGeolocationPermissionsHidePrompt instead')
+ void Function(InAppWebViewController controller)?
+ androidOnGeolocationPermissionsHidePrompt,
+ @Deprecated('Use onGeolocationPermissionsShowPrompt instead')
+ FutureOr Function(
+ InAppWebViewController controller, String origin)?
+ androidOnGeolocationPermissionsShowPrompt,
+ @Deprecated('Use onPermissionRequest instead')
+ FutureOr Function(
+ InAppWebViewController controller,
+ String origin,
+ List resources)?
+ androidOnPermissionRequest,
+ @Deprecated('Use onSafeBrowsingHit instead')
+ FutureOr Function(
+ InAppWebViewController controller,
+ Uri url,
+ SafeBrowsingThreat? threatType)?
+ androidOnSafeBrowsingHit,
+ InAppWebViewInitialData? initialData,
+ String? initialFile,
+ @Deprecated('Use initialSettings instead')
+ InAppWebViewGroupOptions? initialOptions,
+ InAppWebViewSettings? initialSettings,
+ URLRequest? initialUrlRequest,
+ UnmodifiableListView? initialUserScripts,
+ PullToRefreshController? pullToRefreshController,
+ FindInteractionController? findInteractionController,
+ ContextMenu? contextMenu,
+ void Function(InAppWebViewController controller, WebUri? url)?
+ onPageCommitVisible,
+ void Function(InAppWebViewController controller, String? title)?
+ onTitleChanged,
+ @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
+ void Function(InAppWebViewController controller)?
+ iosOnDidReceiveServerRedirectForProvisionalNavigation,
+ @Deprecated('Use onWebContentProcessDidTerminate instead')
+ void Function(InAppWebViewController controller)?
+ iosOnWebContentProcessDidTerminate,
+ @Deprecated('Use onNavigationResponse instead')
+ FutureOr Function(InAppWebViewController controller, IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse,
+ @Deprecated('Use shouldAllowDeprecatedTLS instead') FutureOr Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS,
+ FutureOr Function(InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxProgress,
+ FutureOr Function(InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxReadyStateChange,
+ void Function(InAppWebViewController controller, ConsoleMessage consoleMessage)? onConsoleMessage,
+ FutureOr Function(InAppWebViewController controller, CreateWindowAction createWindowAction)? onCreateWindow,
+ void Function(InAppWebViewController controller)? onCloseWindow,
+ void Function(InAppWebViewController controller)? onWindowFocus,
+ void Function(InAppWebViewController controller)? onWindowBlur,
+ @Deprecated('Use onReceivedIcon instead') void Function(InAppWebViewController controller, Uint8List icon)? androidOnReceivedIcon,
+ @Deprecated('Use onReceivedTouchIconUrl instead') void Function(InAppWebViewController controller, Uri url, bool precomposed)? androidOnReceivedTouchIconUrl,
+ @Deprecated('Use onDownloadStarting instead') void Function(InAppWebViewController controller, Uri url)? onDownloadStart,
+ @Deprecated('Use onDownloadStarting instead') void Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? onDownloadStartRequest,
+ FutureOr Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? onDownloadStarting,
+ @Deprecated('Use FindInteractionController.onFindResultReceived instead') void Function(InAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? onFindResultReceived,
+ FutureOr Function(InAppWebViewController controller, JsAlertRequest jsAlertRequest)? onJsAlert,
+ FutureOr Function(InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)? onJsConfirm,
+ FutureOr Function(InAppWebViewController controller, JsPromptRequest jsPromptRequest)? onJsPrompt,
+ @Deprecated("Use onReceivedError instead") void Function(InAppWebViewController controller, Uri? url, int code, String message)? onLoadError,
+ void Function(InAppWebViewController controller, WebResourceRequest request, WebResourceError error)? onReceivedError,
+ @Deprecated("Use onReceivedHttpError instead") void Function(InAppWebViewController controller, Uri? url, int statusCode, String description)? onLoadHttpError,
+ void Function(InAppWebViewController controller, WebResourceRequest request, WebResourceResponse errorResponse)? onReceivedHttpError,
+ void Function(InAppWebViewController controller, LoadedResource resource)? onLoadResource,
+ @Deprecated('Use onLoadResourceWithCustomScheme instead') FutureOr Function(InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme,
+ FutureOr Function(InAppWebViewController controller, WebResourceRequest request)? onLoadResourceWithCustomScheme,
+ void Function(InAppWebViewController controller, WebUri? url)? onLoadStart,
+ void Function(InAppWebViewController controller, WebUri? url)? onLoadStop,
+ void Function(InAppWebViewController controller, InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult,
+ @Deprecated("Use onPrintRequest instead") void Function(InAppWebViewController controller, Uri? url)? onPrint,
+ FutureOr Function(InAppWebViewController controller, WebUri? url, PlatformPrintJobController? printJobController)? onPrintRequest,
+ void Function(InAppWebViewController controller, int progress)? onProgressChanged,
+ FutureOr Function(InAppWebViewController controller, ClientCertChallenge challenge)? onReceivedClientCertRequest,
+ FutureOr Function(InAppWebViewController controller, HttpAuthenticationChallenge challenge)? onReceivedHttpAuthRequest,
+ FutureOr Function(InAppWebViewController controller, ServerTrustChallenge challenge)? onReceivedServerTrustAuthRequest,
+ void Function(InAppWebViewController controller, int x, int y)? onScrollChanged,
+ void Function(InAppWebViewController controller, WebUri? url, bool? isReload)? onUpdateVisitedHistory,
+ void Function(InAppWebViewController controller)? onWebViewCreated,
+ FutureOr Function(InAppWebViewController controller, AjaxRequest ajaxRequest)? shouldInterceptAjaxRequest,
+ FutureOr Function(InAppWebViewController controller, FetchRequest fetchRequest)? shouldInterceptFetchRequest,
+ FutureOr Function(InAppWebViewController controller, NavigationAction navigationAction)? shouldOverrideUrlLoading,
+ void Function(InAppWebViewController controller)? onEnterFullscreen,
+ void Function(InAppWebViewController controller)? onExitFullscreen,
+ void Function(InAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled,
+ void Function(InAppWebViewController controller, double oldScale, double newScale)? onZoomScaleChanged,
+ @Deprecated('Use shouldInterceptRequest instead') FutureOr Function(InAppWebViewController controller, WebResourceRequest request)? androidShouldInterceptRequest,
+ @Deprecated('Use onRenderProcessUnresponsive instead') FutureOr Function(InAppWebViewController controller, Uri? url)? androidOnRenderProcessUnresponsive,
+ @Deprecated('Use onRenderProcessResponsive instead') FutureOr Function(InAppWebViewController controller, Uri? url)? androidOnRenderProcessResponsive,
+ @Deprecated('Use onRenderProcessGone instead') void Function(InAppWebViewController controller, RenderProcessGoneDetail detail)? androidOnRenderProcessGone,
+ @Deprecated('Use onFormResubmission instead') FutureOr Function(InAppWebViewController controller, Uri? url)? androidOnFormResubmission,
+ @Deprecated('Use onZoomScaleChanged instead') void Function(InAppWebViewController controller, double oldScale, double newScale)? androidOnScaleChanged,
+ @Deprecated('Use onJsBeforeUnload instead') FutureOr Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? androidOnJsBeforeUnload,
+ @Deprecated('Use onReceivedLoginRequest instead') void Function(InAppWebViewController controller, LoginRequest loginRequest)? androidOnReceivedLoginRequest,
+ void Function(InAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation,
+ FutureOr Function(InAppWebViewController controller, WebUri? url)? onFormResubmission,
+ void Function(InAppWebViewController controller)? onGeolocationPermissionsHidePrompt,
+ FutureOr Function(InAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt,
+ FutureOr Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload,
+ FutureOr Function(InAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse,
+ FutureOr Function(InAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequest,
+ void Function(InAppWebViewController controller, Uint8List icon)? onReceivedIcon,
+ void Function(InAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest,
+ void Function(InAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequestCanceled,
+ void Function(InAppWebViewController controller)? onRequestFocus,
+ void Function(InAppWebViewController controller, WebUri url, bool precomposed)? onReceivedTouchIconUrl,
+ void Function(InAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone,
+ FutureOr Function(InAppWebViewController controller, WebUri? url)? onRenderProcessResponsive,
+ FutureOr Function(InAppWebViewController controller, WebUri? url)? onRenderProcessUnresponsive,
+ FutureOr Function(InAppWebViewController controller, WebUri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit,
+ void Function(InAppWebViewController controller)? onWebContentProcessDidTerminate,
+ FutureOr Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS,
+ FutureOr Function(InAppWebViewController controller, WebResourceRequest request)? shouldInterceptRequest,
+ FutureOr Function(
+ InAppWebViewController controller,
+ MediaCaptureState? oldState,
+ MediaCaptureState? newState,
+ )? onCameraCaptureStateChanged,
+ FutureOr Function(
+ InAppWebViewController controller,
+ MediaCaptureState? oldState,
+ MediaCaptureState? newState,
+ )? onMicrophoneCaptureStateChanged,
+ void Function(InAppWebViewController controller, Size oldContentSize, Size newContentSize)? onContentSizeChanged,
+ void Function(InAppWebViewController controller, ProcessFailedDetail detail)? onProcessFailed,
+ void Function(InAppWebViewController controller, AcceleratorKeyPressedDetail detail)? onAcceleratorKeyPressed,
+ FutureOr Function(InAppWebViewController controller, ShowFileChooserRequest request)? onShowFileChooser})
+ : this.fromPlatformCreationParams(
params: PlatformHeadlessInAppWebViewCreationParams(
controllerFromPlatform: (PlatformInAppWebViewController controller) =>
InAppWebViewController.fromPlatform(platform: controller),
@@ -361,6 +236,10 @@ class HeadlessInAppWebView {
? (controller, downloadStartRequest) =>
onDownloadStartRequest.call(controller, downloadStartRequest)
: null,
+ onDownloadStarting: onDownloadStarting != null
+ ? (controller, downloadStartRequest) =>
+ onDownloadStarting.call(controller, downloadStartRequest)
+ : null,
onLoadResourceCustomScheme: onLoadResourceCustomScheme != null
? (controller, url) =>
onLoadResourceCustomScheme.call(controller, url)
@@ -636,6 +515,17 @@ class HeadlessInAppWebView {
onContentSizeChanged.call(
controller, oldContentSize, newContentSize)
: null,
+ onProcessFailed: onProcessFailed != null
+ ? (controller, detail) => onProcessFailed.call(controller, detail)
+ : null,
+ onAcceleratorKeyPressed: onAcceleratorKeyPressed != null
+ ? (controller, detail) =>
+ onAcceleratorKeyPressed.call(controller, detail)
+ : null,
+ onShowFileChooser: onShowFileChooser != null
+ ? (controller, request) =>
+ onShowFileChooser.call(controller, request)
+ : null,
));
///{@macro flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebView.run}
diff --git a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart
index b885aa3c1..6368630e7 100755
--- a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart
+++ b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart
@@ -1,20 +1,19 @@
import 'dart:async';
import 'dart:collection';
-import 'dart:typed_data';
import 'package:flutter/foundation.dart';
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/rendering.dart';
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';
import '../pull_to_refresh/main.dart';
import '../pull_to_refresh/pull_to_refresh_controller.dart';
+import '../webview_environment/webview_environment.dart';
+import 'headless_in_app_webview.dart';
+import 'in_app_webview_controller.dart';
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
class InAppWebView extends StatefulWidget {
@@ -35,266 +34,141 @@ class InAppWebView extends StatefulWidget {
final PlatformInAppWebViewWidget platform;
///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget}
- InAppWebView({
- Key? key,
- Set>? gestureRecognizers,
- int? windowId,
- HeadlessInAppWebView? headlessWebView,
- InAppWebViewKeepAlive? keepAlive,
- bool? preventGestureDelay,
- TextDirection? layoutDirection,
- WebViewEnvironment? webViewEnvironment,
- @Deprecated('Use onGeolocationPermissionsHidePrompt instead')
- void Function(InAppWebViewController controller)?
- androidOnGeolocationPermissionsHidePrompt,
- @Deprecated('Use onGeolocationPermissionsShowPrompt instead')
- Future Function(
- InAppWebViewController controller, String origin)?
- androidOnGeolocationPermissionsShowPrompt,
- @Deprecated('Use onPermissionRequest instead')
- Future Function(
- InAppWebViewController controller,
- String origin,
- List resources)?
- androidOnPermissionRequest,
- @Deprecated('Use onSafeBrowsingHit instead')
- Future Function(InAppWebViewController controller,
- Uri url, SafeBrowsingThreat? threatType)?
- androidOnSafeBrowsingHit,
- InAppWebViewInitialData? initialData,
- String? initialFile,
- @Deprecated('Use initialSettings instead')
- InAppWebViewGroupOptions? initialOptions,
- InAppWebViewSettings? initialSettings,
- URLRequest? initialUrlRequest,
- UnmodifiableListView? initialUserScripts,
- PullToRefreshController? pullToRefreshController,
- FindInteractionController? findInteractionController,
- ContextMenu? contextMenu,
- void Function(InAppWebViewController controller, WebUri? url)?
- onPageCommitVisible,
- void Function(InAppWebViewController controller, String? title)?
- onTitleChanged,
- @Deprecated(
- 'Use onDidReceiveServerRedirectForProvisionalNavigation instead')
- void Function(InAppWebViewController controller)?
- iosOnDidReceiveServerRedirectForProvisionalNavigation,
- @Deprecated('Use onWebContentProcessDidTerminate instead')
- void Function(InAppWebViewController controller)?
- iosOnWebContentProcessDidTerminate,
- @Deprecated('Use onNavigationResponse instead')
- Future Function(
- InAppWebViewController controller,
- IOSWKNavigationResponse navigationResponse)?
- iosOnNavigationResponse,
- @Deprecated('Use shouldAllowDeprecatedTLS instead')
- Future Function(
- InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- iosShouldAllowDeprecatedTLS,
- Future Function(
- InAppWebViewController controller, AjaxRequest ajaxRequest)?
- onAjaxProgress,
- Future Function(
- InAppWebViewController controller, AjaxRequest ajaxRequest)?
- onAjaxReadyStateChange,
- void Function(
- InAppWebViewController controller, ConsoleMessage consoleMessage)?
- onConsoleMessage,
- Future Function(InAppWebViewController controller,
- CreateWindowAction createWindowAction)?
- onCreateWindow,
- void Function(InAppWebViewController controller)? onCloseWindow,
- void Function(InAppWebViewController controller)? onWindowFocus,
- void Function(InAppWebViewController controller)? onWindowBlur,
- @Deprecated('Use onReceivedIcon instead')
- void Function(InAppWebViewController controller, Uint8List icon)?
- androidOnReceivedIcon,
- @Deprecated('Use onReceivedTouchIconUrl instead')
- void Function(InAppWebViewController controller, Uri url, bool precomposed)?
- androidOnReceivedTouchIconUrl,
- @Deprecated('Use onDownloadStartRequest instead')
- void Function(InAppWebViewController controller, Uri url)? onDownloadStart,
- void Function(InAppWebViewController controller,
- DownloadStartRequest downloadStartRequest)?
- onDownloadStartRequest,
- @Deprecated('Use FindInteractionController.onFindResultReceived instead')
- void Function(InAppWebViewController controller, int activeMatchOrdinal,
- int numberOfMatches, bool isDoneCounting)?
- onFindResultReceived,
- Future Function(
- InAppWebViewController controller, JsAlertRequest jsAlertRequest)?
- onJsAlert,
- Future Function(InAppWebViewController controller,
- JsConfirmRequest jsConfirmRequest)?
- onJsConfirm,
- Future Function(
- InAppWebViewController controller, JsPromptRequest jsPromptRequest)?
- onJsPrompt,
- @Deprecated("Use onReceivedError instead")
- void Function(InAppWebViewController controller, Uri? url, int code,
- String message)?
- onLoadError,
- void Function(InAppWebViewController controller, WebResourceRequest request,
- WebResourceError error)?
- onReceivedError,
- @Deprecated("Use onReceivedHttpError instead")
- void Function(InAppWebViewController controller, Uri? url, int statusCode,
- String description)?
- onLoadHttpError,
- void Function(InAppWebViewController controller, WebResourceRequest request,
- WebResourceResponse errorResponse)?
- onReceivedHttpError,
- void Function(InAppWebViewController controller, LoadedResource resource)?
- onLoadResource,
- @Deprecated('Use onLoadResourceWithCustomScheme instead')
- Future Function(
- InAppWebViewController controller, Uri url)?
- onLoadResourceCustomScheme,
- Future Function(
- InAppWebViewController controller, WebResourceRequest request)?
- onLoadResourceWithCustomScheme,
- void Function(InAppWebViewController controller, WebUri? url)? onLoadStart,
- void Function(InAppWebViewController controller, WebUri? url)? onLoadStop,
- void Function(InAppWebViewController controller,
- InAppWebViewHitTestResult hitTestResult)?
- onLongPressHitTestResult,
- @Deprecated("Use onPrintRequest instead")
- void Function(InAppWebViewController controller, Uri? url)? onPrint,
- Future Function(InAppWebViewController controller, WebUri? url,
- PlatformPrintJobController? printJobController)?
- onPrintRequest,
- void Function(InAppWebViewController controller, int progress)?
- onProgressChanged,
- Future Function(InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- onReceivedClientCertRequest,
- Future Function(InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- onReceivedHttpAuthRequest,
- Future Function(InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- onReceivedServerTrustAuthRequest,
- void Function(InAppWebViewController controller, int x, int y)?
- onScrollChanged,
- void Function(
- InAppWebViewController controller, WebUri? url, bool? isReload)?
- onUpdateVisitedHistory,
- void Function(InAppWebViewController controller)? onWebViewCreated,
- Future Function(
- InAppWebViewController controller, AjaxRequest ajaxRequest)?
- shouldInterceptAjaxRequest,
- Future Function(
- InAppWebViewController controller, FetchRequest fetchRequest)?
- shouldInterceptFetchRequest,
- Future Function(InAppWebViewController controller,
- NavigationAction navigationAction)?
- shouldOverrideUrlLoading,
- void Function(InAppWebViewController controller)? onEnterFullscreen,
- void Function(InAppWebViewController controller)? onExitFullscreen,
- void Function(InAppWebViewController controller, int x, int y,
- bool clampedX, bool clampedY)?
- onOverScrolled,
- void Function(InAppWebViewController controller, double oldScale,
- double newScale)?
- onZoomScaleChanged,
- @Deprecated('Use shouldInterceptRequest instead')
- Future Function(
- InAppWebViewController controller, WebResourceRequest request)?
- androidShouldInterceptRequest,
- @Deprecated('Use onRenderProcessUnresponsive instead')
- Future Function(
- InAppWebViewController controller, Uri? url)?
- androidOnRenderProcessUnresponsive,
- @Deprecated('Use onRenderProcessResponsive instead')
- Future Function(
- InAppWebViewController controller, Uri? url)?
- androidOnRenderProcessResponsive,
- @Deprecated('Use onRenderProcessGone instead')
- void Function(
- InAppWebViewController controller, RenderProcessGoneDetail detail)?
- androidOnRenderProcessGone,
- @Deprecated('Use onFormResubmission instead')
- Future Function(
- InAppWebViewController controller, Uri? url)?
- androidOnFormResubmission,
- @Deprecated('Use onZoomScaleChanged instead')
- void Function(InAppWebViewController controller, double oldScale,
- double newScale)?
- androidOnScaleChanged,
- @Deprecated('Use onJsBeforeUnload instead')
- Future Function(InAppWebViewController controller,
- JsBeforeUnloadRequest jsBeforeUnloadRequest)?
- androidOnJsBeforeUnload,
- @Deprecated('Use onReceivedLoginRequest instead')
- void Function(InAppWebViewController controller, LoginRequest loginRequest)?
- androidOnReceivedLoginRequest,
- void Function(InAppWebViewController controller)?
- onDidReceiveServerRedirectForProvisionalNavigation,
- Future Function(
- InAppWebViewController controller, WebUri? url)?
- onFormResubmission,
- void Function(InAppWebViewController controller)?
- onGeolocationPermissionsHidePrompt,
- Future Function(
- InAppWebViewController controller, String origin)?
- onGeolocationPermissionsShowPrompt,
- Future Function(InAppWebViewController controller,
- JsBeforeUnloadRequest jsBeforeUnloadRequest)?
- onJsBeforeUnload,
- Future Function(
- InAppWebViewController controller,
- NavigationResponse navigationResponse)?
- onNavigationResponse,
- Future Function(InAppWebViewController controller,
- PermissionRequest permissionRequest)?
- onPermissionRequest,
- void Function(InAppWebViewController controller, Uint8List icon)?
- onReceivedIcon,
- void Function(InAppWebViewController controller, LoginRequest loginRequest)?
- onReceivedLoginRequest,
- void Function(InAppWebViewController controller,
- PermissionRequest permissionRequest)?
- onPermissionRequestCanceled,
- void Function(InAppWebViewController controller)? onRequestFocus,
- void Function(
- InAppWebViewController controller, WebUri url, bool precomposed)?
- onReceivedTouchIconUrl,
- void Function(
- InAppWebViewController controller, RenderProcessGoneDetail detail)?
- onRenderProcessGone,
- Future Function(
- InAppWebViewController controller, WebUri? url)?
- onRenderProcessResponsive,
- Future Function(
- InAppWebViewController controller, WebUri? url)?
- onRenderProcessUnresponsive,
- Future Function(InAppWebViewController controller,
- WebUri url, SafeBrowsingThreat? threatType)?
- onSafeBrowsingHit,
- void Function(InAppWebViewController controller)?
- onWebContentProcessDidTerminate,
- Future Function(
- InAppWebViewController controller,
- URLAuthenticationChallenge challenge)?
- shouldAllowDeprecatedTLS,
- Future Function(
- InAppWebViewController controller, WebResourceRequest request)?
- shouldInterceptRequest,
- Future Function(
- InAppWebViewController controller,
- MediaCaptureState? oldState,
- MediaCaptureState? newState,
- )? onCameraCaptureStateChanged,
- Future Function(
- InAppWebViewController controller,
- MediaCaptureState? oldState,
- MediaCaptureState? newState,
- )? onMicrophoneCaptureStateChanged,
- void Function(InAppWebViewController controller, Size oldContentSize,
- Size newContentSize)?
- onContentSizeChanged,
- }) : this.fromPlatformCreationParams(
+ InAppWebView(
+ {Key? key,
+ Set>? gestureRecognizers,
+ int? windowId,
+ HeadlessInAppWebView? headlessWebView,
+ InAppWebViewKeepAlive? keepAlive,
+ bool? preventGestureDelay,
+ TextDirection? layoutDirection,
+ WebViewEnvironment? webViewEnvironment,
+ @Deprecated('Use onGeolocationPermissionsHidePrompt instead')
+ void Function(InAppWebViewController controller)?
+ androidOnGeolocationPermissionsHidePrompt,
+ @Deprecated('Use onGeolocationPermissionsShowPrompt instead')
+ FutureOr Function(
+ InAppWebViewController controller, String origin)?
+ androidOnGeolocationPermissionsShowPrompt,
+ @Deprecated('Use onPermissionRequest instead')
+ FutureOr Function(
+ InAppWebViewController controller,
+ String origin,
+ List resources)?
+ androidOnPermissionRequest,
+ @Deprecated('Use onSafeBrowsingHit instead')
+ FutureOr Function(
+ InAppWebViewController controller,
+ Uri url,
+ SafeBrowsingThreat? threatType)?
+ androidOnSafeBrowsingHit,
+ InAppWebViewInitialData? initialData,
+ String? initialFile,
+ @Deprecated('Use initialSettings instead')
+ InAppWebViewGroupOptions? initialOptions,
+ InAppWebViewSettings? initialSettings,
+ URLRequest? initialUrlRequest,
+ UnmodifiableListView? initialUserScripts,
+ PullToRefreshController? pullToRefreshController,
+ FindInteractionController? findInteractionController,
+ ContextMenu? contextMenu,
+ void Function(InAppWebViewController controller, WebUri? url)?
+ onPageCommitVisible,
+ void Function(InAppWebViewController controller, String? title)?
+ onTitleChanged,
+ @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
+ void Function(InAppWebViewController controller)?
+ iosOnDidReceiveServerRedirectForProvisionalNavigation,
+ @Deprecated('Use onWebContentProcessDidTerminate instead')
+ void Function(InAppWebViewController controller)?
+ iosOnWebContentProcessDidTerminate,
+ @Deprecated('Use onNavigationResponse instead')
+ FutureOr Function(InAppWebViewController controller, IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse,
+ @Deprecated('Use shouldAllowDeprecatedTLS instead') FutureOr Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS,
+ FutureOr Function(InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxProgress,
+ FutureOr Function(InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxReadyStateChange,
+ void Function(InAppWebViewController controller, ConsoleMessage consoleMessage)? onConsoleMessage,
+ FutureOr Function(InAppWebViewController controller, CreateWindowAction createWindowAction)? onCreateWindow,
+ void Function(InAppWebViewController controller)? onCloseWindow,
+ void Function(InAppWebViewController controller)? onWindowFocus,
+ void Function(InAppWebViewController controller)? onWindowBlur,
+ @Deprecated('Use onReceivedIcon instead') void Function(InAppWebViewController controller, Uint8List icon)? androidOnReceivedIcon,
+ @Deprecated('Use onReceivedTouchIconUrl instead') void Function(InAppWebViewController controller, Uri url, bool precomposed)? androidOnReceivedTouchIconUrl,
+ @Deprecated('Use onDownloadStarting instead') void Function(InAppWebViewController controller, Uri url)? onDownloadStart,
+ @Deprecated('Use onDownloadStarting instead') void Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? onDownloadStartRequest,
+ FutureOr Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? onDownloadStarting,
+ @Deprecated('Use FindInteractionController.onFindResultReceived instead') void Function(InAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? onFindResultReceived,
+ FutureOr Function(InAppWebViewController controller, JsAlertRequest jsAlertRequest)? onJsAlert,
+ FutureOr Function(InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)? onJsConfirm,
+ FutureOr Function(InAppWebViewController controller, JsPromptRequest jsPromptRequest)? onJsPrompt,
+ @Deprecated("Use onReceivedError instead") void Function(InAppWebViewController controller, Uri? url, int code, String message)? onLoadError,
+ void Function(InAppWebViewController controller, WebResourceRequest request, WebResourceError error)? onReceivedError,
+ @Deprecated("Use onReceivedHttpError instead") void Function(InAppWebViewController controller, Uri? url, int statusCode, String description)? onLoadHttpError,
+ void Function(InAppWebViewController controller, WebResourceRequest request, WebResourceResponse errorResponse)? onReceivedHttpError,
+ void Function(InAppWebViewController controller, LoadedResource resource)? onLoadResource,
+ @Deprecated('Use onLoadResourceWithCustomScheme instead') FutureOr Function(InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme,
+ FutureOr Function(InAppWebViewController controller, WebResourceRequest request)? onLoadResourceWithCustomScheme,
+ void Function(InAppWebViewController controller, WebUri? url)? onLoadStart,
+ void Function(InAppWebViewController controller, WebUri? url)? onLoadStop,
+ void Function(InAppWebViewController controller, InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult,
+ @Deprecated("Use onPrintRequest instead") void Function(InAppWebViewController controller, Uri? url)? onPrint,
+ FutureOr Function(InAppWebViewController controller, WebUri? url, PlatformPrintJobController? printJobController)? onPrintRequest,
+ void Function(InAppWebViewController controller, int progress)? onProgressChanged,
+ FutureOr Function(InAppWebViewController controller, ClientCertChallenge challenge)? onReceivedClientCertRequest,
+ FutureOr