fixed last android implementations, updated analysis_options files
This commit is contained in:
parent
d57af8eb46
commit
a25c1bd50e
|
@ -3,9 +3,11 @@ include: package:flutter_lints/flutter.yaml
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
constant_identifier_names: ignore
|
constant_identifier_names: ignore
|
||||||
|
deprecated_member_use_from_same_package: ignore
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
# Additional information about this file can be found at
|
||||||
# https://dart.dev/guides/language/analysis-options
|
# https://dart.dev/guides/language/analysis-options
|
||||||
analyzer:
|
analyzer:
|
||||||
errors:
|
errors:
|
||||||
|
deprecated_member_use: ignore
|
||||||
deprecated_member_use_from_same_package: ignore
|
deprecated_member_use_from_same_package: ignore
|
|
@ -1,12 +1,8 @@
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import '../constants.dart';
|
|
||||||
import '../env.dart';
|
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
part 'apply.dart';
|
part 'apply.dart';
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,11 @@ include: package:flutter_lints/flutter.yaml
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
constant_identifier_names: ignore
|
constant_identifier_names: ignore
|
||||||
|
deprecated_member_use_from_same_package: ignore
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
# Additional information about this file can be found at
|
||||||
# https://dart.dev/guides/language/analysis-options
|
# https://dart.dev/guides/language/analysis-options
|
||||||
analyzer:
|
analyzer:
|
||||||
errors:
|
errors:
|
||||||
|
deprecated_member_use: ignore
|
||||||
deprecated_member_use_from_same_package: ignore
|
deprecated_member_use_from_same_package: ignore
|
|
@ -111,8 +111,9 @@ class AndroidChromeSafariBrowser extends PlatformChromeSafariBrowser
|
||||||
break;
|
break;
|
||||||
case "onClosed":
|
case "onClosed":
|
||||||
_isOpened = false;
|
_isOpened = false;
|
||||||
|
final onClosed = eventHandler?.onClosed;
|
||||||
dispose();
|
dispose();
|
||||||
eventHandler?.onClosed();
|
onClosed?.call();
|
||||||
break;
|
break;
|
||||||
case "onItemActionPerform":
|
case "onItemActionPerform":
|
||||||
String url = call.arguments["url"];
|
String url = call.arguments["url"];
|
||||||
|
@ -402,5 +403,6 @@ class AndroidChromeSafariBrowser extends PlatformChromeSafariBrowser
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
void dispose() {
|
void dispose() {
|
||||||
disposeChannel();
|
disposeChannel();
|
||||||
|
eventHandler = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,8 +131,9 @@ class AndroidInAppBrowser extends PlatformInAppBrowser with ChannelController {
|
||||||
case "onExit":
|
case "onExit":
|
||||||
_debugLog(call.method, call.arguments);
|
_debugLog(call.method, call.arguments);
|
||||||
_isOpened = false;
|
_isOpened = false;
|
||||||
|
final onExit = eventHandler?.onExit;
|
||||||
dispose();
|
dispose();
|
||||||
eventHandler?.onExit();
|
onExit?.call();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return _webViewController?.handleMethod(call);
|
return _webViewController?.handleMethod(call);
|
||||||
|
|
|
@ -164,8 +164,9 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController
|
||||||
params.webviewParams?.controllerFromPlatform?.call(this) ?? this;
|
params.webviewParams?.controllerFromPlatform?.call(this) ?? this;
|
||||||
|
|
||||||
webStorage = AndroidWebStorage(AndroidWebStorageCreationParams(
|
webStorage = AndroidWebStorage(AndroidWebStorageCreationParams(
|
||||||
localStorage: AndroidLocalStorage.defaultStorage(),
|
localStorage: AndroidLocalStorage.defaultStorage(controller: this),
|
||||||
sessionStorage: AndroidSessionStorage.defaultStorage()));
|
sessionStorage:
|
||||||
|
AndroidSessionStorage.defaultStorage(controller: this)));
|
||||||
|
|
||||||
if (params.webviewParams is PlatformInAppWebViewWidgetCreationParams) {
|
if (params.webviewParams is PlatformInAppWebViewWidgetCreationParams) {
|
||||||
final keepAlive =
|
final keepAlive =
|
||||||
|
@ -1018,7 +1019,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController
|
||||||
_controllerFromPlatform, permissionRequest))
|
_controllerFromPlatform, permissionRequest))
|
||||||
?.toMap();
|
?.toMap();
|
||||||
else {
|
else {
|
||||||
// ignore: deprecated_member_use_from_same_package
|
|
||||||
return (await webviewParams!.androidOnPermissionRequest!(
|
return (await webviewParams!.androidOnPermissionRequest!(
|
||||||
_controllerFromPlatform, origin, resources))
|
_controllerFromPlatform, origin, resources))
|
||||||
?.toMap();
|
?.toMap();
|
||||||
|
|
|
@ -150,16 +150,6 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
return AndroidWebStorage(params);
|
return AndroidWebStorage(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [AndroidStorage].
|
|
||||||
///
|
|
||||||
/// This function should only be called by the app-facing package.
|
|
||||||
/// Look at using [AndroidStorage] in `flutter_inappwebview` instead.
|
|
||||||
AndroidStorage createPlatformStorage(
|
|
||||||
PlatformStorageCreationParams params,
|
|
||||||
) {
|
|
||||||
return AndroidStorage(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new [AndroidLocalStorage].
|
/// Creates a new [AndroidLocalStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
|
@ -266,16 +256,6 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
return AndroidTracingController(params);
|
return AndroidTracingController(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [AndroidPathHandler].
|
|
||||||
///
|
|
||||||
/// This function should only be called by the app-facing package.
|
|
||||||
/// Look at using [PathHandler] in `flutter_inappwebview` instead.
|
|
||||||
AndroidPathHandler createPlatformPathHandler(
|
|
||||||
PlatformPathHandlerCreationParams params,
|
|
||||||
) {
|
|
||||||
return AndroidPathHandler(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new [AndroidAssetsPathHandler].
|
/// Creates a new [AndroidAssetsPathHandler].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
|
|
|
@ -75,19 +75,15 @@ class AndroidServiceWorkerController extends PlatformServiceWorkerController
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
AndroidServiceWorkerController controller =
|
|
||||||
AndroidServiceWorkerController.instance();
|
|
||||||
ServiceWorkerClient? serviceWorkerClient = controller._serviceWorkerClient;
|
|
||||||
|
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "shouldInterceptRequest":
|
case "shouldInterceptRequest":
|
||||||
if (serviceWorkerClient != null &&
|
if (serviceWorkerClient != null &&
|
||||||
serviceWorkerClient.shouldInterceptRequest != null) {
|
serviceWorkerClient!.shouldInterceptRequest != null) {
|
||||||
Map<String, dynamic> arguments =
|
Map<String, dynamic> arguments =
|
||||||
call.arguments.cast<String, dynamic>();
|
call.arguments.cast<String, dynamic>();
|
||||||
WebResourceRequest request = WebResourceRequest.fromMap(arguments)!;
|
WebResourceRequest request = WebResourceRequest.fromMap(arguments)!;
|
||||||
|
|
||||||
return (await serviceWorkerClient.shouldInterceptRequest!(request))
|
return (await serviceWorkerClient!.shouldInterceptRequest!(request))
|
||||||
?.toMap();
|
?.toMap();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,33 +56,27 @@ class AndroidWebStorage extends PlatformWebStorage {
|
||||||
/// more information.
|
/// more information.
|
||||||
class AndroidStorageCreationParams extends PlatformStorageCreationParams {
|
class AndroidStorageCreationParams extends PlatformStorageCreationParams {
|
||||||
/// Creates a new [AndroidStorageCreationParams] instance.
|
/// Creates a new [AndroidStorageCreationParams] instance.
|
||||||
AndroidStorageCreationParams({required super.webStorageType});
|
AndroidStorageCreationParams(
|
||||||
|
{required super.controller, required super.webStorageType});
|
||||||
|
|
||||||
/// Creates a [AndroidStorageCreationParams] instance based on [PlatformStorageCreationParams].
|
/// Creates a [AndroidStorageCreationParams] instance based on [PlatformStorageCreationParams].
|
||||||
factory AndroidStorageCreationParams.fromPlatformStorageCreationParams(
|
factory AndroidStorageCreationParams.fromPlatformStorageCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformStorageCreationParams params) {
|
PlatformStorageCreationParams params) {
|
||||||
return AndroidStorageCreationParams(webStorageType: params.webStorageType);
|
return AndroidStorageCreationParams(
|
||||||
|
controller: params.controller, webStorageType: params.webStorageType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
|
||||||
class AndroidStorage extends PlatformStorage {
|
abstract class AndroidStorage implements PlatformStorage {
|
||||||
/// Constructs a [AndroidStorage].
|
@override
|
||||||
AndroidStorage(PlatformStorageCreationParams params)
|
AndroidInAppWebViewController? controller;
|
||||||
: super.implementation(
|
|
||||||
params is AndroidStorageCreationParams
|
|
||||||
? params
|
|
||||||
: AndroidStorageCreationParams.fromPlatformStorageCreationParams(
|
|
||||||
params),
|
|
||||||
);
|
|
||||||
|
|
||||||
AndroidInAppWebViewController? _controller;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int?> length() async {
|
Future<int?> length() async {
|
||||||
var result = await _controller?.evaluateJavascript(source: """
|
var result = await controller?.evaluateJavascript(source: """
|
||||||
window.$webStorageType.length;
|
window.$webStorageType.length;
|
||||||
""");
|
""");
|
||||||
return result != null ? int.parse(json.decode(result)) : null;
|
return result != null ? int.parse(json.decode(result)) : null;
|
||||||
|
@ -91,14 +85,14 @@ class AndroidStorage extends PlatformStorage {
|
||||||
@override
|
@override
|
||||||
Future<void> setItem({required String key, required dynamic value}) async {
|
Future<void> setItem({required String key, required dynamic value}) async {
|
||||||
var encodedValue = json.encode(value);
|
var encodedValue = json.encode(value);
|
||||||
await _controller?.evaluateJavascript(source: """
|
await controller?.evaluateJavascript(source: """
|
||||||
window.$webStorageType.setItem("$key", ${value is String ? encodedValue : "JSON.stringify($encodedValue)"});
|
window.$webStorageType.setItem("$key", ${value is String ? encodedValue : "JSON.stringify($encodedValue)"});
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<dynamic> getItem({required String key}) async {
|
Future<dynamic> getItem({required String key}) async {
|
||||||
var itemValue = await _controller?.evaluateJavascript(source: """
|
var itemValue = await controller?.evaluateJavascript(source: """
|
||||||
window.$webStorageType.getItem("$key");
|
window.$webStorageType.getItem("$key");
|
||||||
""");
|
""");
|
||||||
|
|
||||||
|
@ -115,7 +109,7 @@ class AndroidStorage extends PlatformStorage {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> removeItem({required String key}) async {
|
Future<void> removeItem({required String key}) async {
|
||||||
await _controller?.evaluateJavascript(source: """
|
await controller?.evaluateJavascript(source: """
|
||||||
window.$webStorageType.removeItem("$key");
|
window.$webStorageType.removeItem("$key");
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
@ -125,7 +119,7 @@ class AndroidStorage extends PlatformStorage {
|
||||||
var webStorageItems = <WebStorageItem>[];
|
var webStorageItems = <WebStorageItem>[];
|
||||||
|
|
||||||
List<Map<dynamic, dynamic>>? items =
|
List<Map<dynamic, dynamic>>? items =
|
||||||
(await _controller?.evaluateJavascript(source: """
|
(await controller?.evaluateJavascript(source: """
|
||||||
(function() {
|
(function() {
|
||||||
var webStorageItems = [];
|
var webStorageItems = [];
|
||||||
for(var i = 0; i < window.$webStorageType.length; i++){
|
for(var i = 0; i < window.$webStorageType.length; i++){
|
||||||
|
@ -139,7 +133,7 @@ class AndroidStorage extends PlatformStorage {
|
||||||
}
|
}
|
||||||
return webStorageItems;
|
return webStorageItems;
|
||||||
})();
|
})();
|
||||||
""")).cast<Map<dynamic, dynamic>>();
|
"""))?.cast<Map<dynamic, dynamic>>();
|
||||||
|
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
return webStorageItems;
|
return webStorageItems;
|
||||||
|
@ -155,14 +149,14 @@ class AndroidStorage extends PlatformStorage {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> clear() async {
|
Future<void> clear() async {
|
||||||
await _controller?.evaluateJavascript(source: """
|
await controller?.evaluateJavascript(source: """
|
||||||
window.$webStorageType.clear();
|
window.$webStorageType.clear();
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<String> key({required int index}) async {
|
Future<String> key({required int index}) async {
|
||||||
var result = await _controller?.evaluateJavascript(source: """
|
var result = await controller?.evaluateJavascript(source: """
|
||||||
window.$webStorageType.key($index);
|
window.$webStorageType.key($index);
|
||||||
""");
|
""");
|
||||||
return result != null ? json.decode(result) : null;
|
return result != null ? json.decode(result) : null;
|
||||||
|
@ -170,7 +164,7 @@ class AndroidStorage extends PlatformStorage {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controller = null;
|
controller = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,11 +188,10 @@ class AndroidLocalStorageCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
||||||
class AndroidLocalStorage extends AndroidStorage
|
class AndroidLocalStorage extends PlatformLocalStorage with AndroidStorage {
|
||||||
implements PlatformLocalStorage {
|
|
||||||
/// Constructs a [AndroidLocalStorage].
|
/// Constructs a [AndroidLocalStorage].
|
||||||
AndroidLocalStorage(PlatformLocalStorageCreationParams params)
|
AndroidLocalStorage(PlatformLocalStorageCreationParams params)
|
||||||
: super(
|
: super.implementation(
|
||||||
params is AndroidLocalStorageCreationParams
|
params is AndroidLocalStorageCreationParams
|
||||||
? params
|
? params
|
||||||
: AndroidLocalStorageCreationParams
|
: AndroidLocalStorageCreationParams
|
||||||
|
@ -206,11 +199,17 @@ class AndroidLocalStorage extends AndroidStorage
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Default storage
|
/// Default storage
|
||||||
factory AndroidLocalStorage.defaultStorage() {
|
factory AndroidLocalStorage.defaultStorage(
|
||||||
|
{required PlatformInAppWebViewController? controller}) {
|
||||||
return AndroidLocalStorage(AndroidLocalStorageCreationParams(
|
return AndroidLocalStorage(AndroidLocalStorageCreationParams(
|
||||||
PlatformLocalStorageCreationParams(PlatformStorageCreationParams(
|
PlatformLocalStorageCreationParams(PlatformStorageCreationParams(
|
||||||
|
controller: controller,
|
||||||
webStorageType: WebStorageType.LOCAL_STORAGE))));
|
webStorageType: WebStorageType.LOCAL_STORAGE))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AndroidInAppWebViewController? get controller =>
|
||||||
|
params.controller as AndroidInAppWebViewController?;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [AndroidSessionStorage].
|
/// Object specifying creation parameters for creating a [AndroidSessionStorage].
|
||||||
|
@ -233,11 +232,10 @@ class AndroidSessionStorageCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
||||||
class AndroidSessionStorage extends AndroidStorage
|
class AndroidSessionStorage extends PlatformSessionStorage with AndroidStorage {
|
||||||
implements PlatformSessionStorage {
|
|
||||||
/// Constructs a [AndroidSessionStorage].
|
/// Constructs a [AndroidSessionStorage].
|
||||||
AndroidSessionStorage(PlatformSessionStorageCreationParams params)
|
AndroidSessionStorage(PlatformSessionStorageCreationParams params)
|
||||||
: super(
|
: super.implementation(
|
||||||
params is AndroidSessionStorageCreationParams
|
params is AndroidSessionStorageCreationParams
|
||||||
? params
|
? params
|
||||||
: AndroidSessionStorageCreationParams
|
: AndroidSessionStorageCreationParams
|
||||||
|
@ -245,9 +243,15 @@ class AndroidSessionStorage extends AndroidStorage
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Default storage
|
/// Default storage
|
||||||
factory AndroidSessionStorage.defaultStorage() {
|
factory AndroidSessionStorage.defaultStorage(
|
||||||
|
{required PlatformInAppWebViewController? controller}) {
|
||||||
return AndroidSessionStorage(AndroidSessionStorageCreationParams(
|
return AndroidSessionStorage(AndroidSessionStorageCreationParams(
|
||||||
PlatformSessionStorageCreationParams(PlatformStorageCreationParams(
|
PlatformSessionStorageCreationParams(PlatformStorageCreationParams(
|
||||||
|
controller: controller,
|
||||||
webStorageType: WebStorageType.SESSION_STORAGE))));
|
webStorageType: WebStorageType.SESSION_STORAGE))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AndroidInAppWebViewController? get controller =>
|
||||||
|
params.controller as AndroidInAppWebViewController?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,26 +25,24 @@ class AndroidPathHandlerCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler}
|
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler}
|
||||||
class AndroidPathHandler extends PlatformPathHandler with ChannelController {
|
abstract class AndroidPathHandler
|
||||||
/// Creates a new [AndroidPathHandler].
|
implements ChannelController, PlatformPathHandler {
|
||||||
AndroidPathHandler(PlatformPathHandlerCreationParams params)
|
final String _id = IdGenerator.generate();
|
||||||
: super.implementation(
|
|
||||||
params is AndroidPathHandlerCreationParams
|
@override
|
||||||
? params
|
late final PlatformPathHandlerEvents? eventHandler;
|
||||||
: AndroidPathHandlerCreationParams
|
|
||||||
.fromPlatformPathHandlerCreationParams(params),
|
@override
|
||||||
) {
|
late final String path;
|
||||||
_type = this.runtimeType.toString();
|
|
||||||
_id = IdGenerator.generate();
|
void _init(PlatformPathHandlerCreationParams params) {
|
||||||
|
this.path = params.path;
|
||||||
channel = MethodChannel(
|
channel = MethodChannel(
|
||||||
'com.pichillilorenzo/flutter_inappwebview_custompathhandler_${_id}');
|
'com.pichillilorenzo/flutter_inappwebview_custompathhandler_${_id}');
|
||||||
handler = _handleMethod;
|
handler = _handleMethod;
|
||||||
initMethodCallHandler();
|
initMethodCallHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
late final String _type;
|
|
||||||
late final String _id;
|
|
||||||
|
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "handle":
|
case "handle":
|
||||||
|
@ -57,7 +55,7 @@ class AndroidPathHandler extends PlatformPathHandler with ChannelController {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {"path": path, "type": _type, "id": _id};
|
return {"path": path, "type": type, "id": _id};
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -67,7 +65,7 @@ class AndroidPathHandler extends PlatformPathHandler with ChannelController {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AndroidPathHandler{path: $path}';
|
return 'AndroidPathHandler{path: $path, type: $type}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -100,16 +98,18 @@ class AndroidAssetsPathHandlerCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformAssetsPathHandler}
|
///{@macro flutter_inappwebview_platform_interface.PlatformAssetsPathHandler}
|
||||||
class AndroidAssetsPathHandler extends AndroidPathHandler
|
class AndroidAssetsPathHandler extends PlatformAssetsPathHandler
|
||||||
implements PlatformAssetsPathHandler {
|
with AndroidPathHandler, ChannelController {
|
||||||
/// Constructs a [AndroidAssetsPathHandler].
|
/// Constructs a [AndroidAssetsPathHandler].
|
||||||
AndroidAssetsPathHandler(PlatformAssetsPathHandlerCreationParams params)
|
AndroidAssetsPathHandler(PlatformAssetsPathHandlerCreationParams params)
|
||||||
: super(
|
: super.implementation(
|
||||||
params is AndroidAssetsPathHandlerCreationParams
|
params is AndroidAssetsPathHandlerCreationParams
|
||||||
? params
|
? params
|
||||||
: AndroidAssetsPathHandlerCreationParams
|
: AndroidAssetsPathHandlerCreationParams
|
||||||
.fromPlatformAssetsPathHandlerCreationParams(params),
|
.fromPlatformAssetsPathHandlerCreationParams(params),
|
||||||
);
|
) {
|
||||||
|
_init(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [AndroidResourcesPathHandler].
|
/// Object specifying creation parameters for creating a [AndroidResourcesPathHandler].
|
||||||
|
@ -135,16 +135,18 @@ class AndroidResourcesPathHandlerCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformResourcesPathHandler}
|
///{@macro flutter_inappwebview_platform_interface.PlatformResourcesPathHandler}
|
||||||
class AndroidResourcesPathHandler extends AndroidPathHandler
|
class AndroidResourcesPathHandler extends PlatformResourcesPathHandler
|
||||||
implements PlatformResourcesPathHandler {
|
with AndroidPathHandler, ChannelController {
|
||||||
/// Constructs a [AndroidResourcesPathHandler].
|
/// Constructs a [AndroidResourcesPathHandler].
|
||||||
AndroidResourcesPathHandler(PlatformResourcesPathHandlerCreationParams params)
|
AndroidResourcesPathHandler(PlatformResourcesPathHandlerCreationParams params)
|
||||||
: super(
|
: super.implementation(
|
||||||
params is AndroidResourcesPathHandlerCreationParams
|
params is AndroidResourcesPathHandlerCreationParams
|
||||||
? params
|
? params
|
||||||
: AndroidResourcesPathHandlerCreationParams
|
: AndroidResourcesPathHandlerCreationParams
|
||||||
.fromPlatformResourcesPathHandlerCreationParams(params),
|
.fromPlatformResourcesPathHandlerCreationParams(params),
|
||||||
);
|
) {
|
||||||
|
_init(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [AndroidInternalStoragePathHandler].
|
/// Object specifying creation parameters for creating a [AndroidInternalStoragePathHandler].
|
||||||
|
@ -170,17 +172,20 @@ class AndroidInternalStoragePathHandlerCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformInternalStoragePathHandler}
|
///{@macro flutter_inappwebview_platform_interface.PlatformInternalStoragePathHandler}
|
||||||
class AndroidInternalStoragePathHandler extends AndroidPathHandler
|
class AndroidInternalStoragePathHandler
|
||||||
implements PlatformInternalStoragePathHandler {
|
extends PlatformInternalStoragePathHandler
|
||||||
|
with AndroidPathHandler, ChannelController {
|
||||||
/// Constructs a [AndroidInternalStoragePathHandler].
|
/// Constructs a [AndroidInternalStoragePathHandler].
|
||||||
AndroidInternalStoragePathHandler(
|
AndroidInternalStoragePathHandler(
|
||||||
PlatformInternalStoragePathHandlerCreationParams params)
|
PlatformInternalStoragePathHandlerCreationParams params)
|
||||||
: super(
|
: super.implementation(
|
||||||
params is AndroidInternalStoragePathHandlerCreationParams
|
params is AndroidInternalStoragePathHandlerCreationParams
|
||||||
? params
|
? params
|
||||||
: AndroidInternalStoragePathHandlerCreationParams
|
: AndroidInternalStoragePathHandlerCreationParams
|
||||||
.fromPlatformInternalStoragePathHandlerCreationParams(params),
|
.fromPlatformInternalStoragePathHandlerCreationParams(params),
|
||||||
);
|
) {
|
||||||
|
_init(params);
|
||||||
|
}
|
||||||
|
|
||||||
AndroidInternalStoragePathHandlerCreationParams get _internalParams =>
|
AndroidInternalStoragePathHandlerCreationParams get _internalParams =>
|
||||||
params as AndroidInternalStoragePathHandlerCreationParams;
|
params as AndroidInternalStoragePathHandlerCreationParams;
|
||||||
|
|
|
@ -3,9 +3,11 @@ include: package:flutter_lints/flutter.yaml
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
constant_identifier_names: ignore
|
constant_identifier_names: ignore
|
||||||
|
deprecated_member_use_from_same_package: ignore
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
# Additional information about this file can be found at
|
||||||
# https://dart.dev/guides/language/analysis-options
|
# https://dart.dev/guides/language/analysis-options
|
||||||
analyzer:
|
analyzer:
|
||||||
errors:
|
errors:
|
||||||
|
deprecated_member_use: ignore
|
||||||
deprecated_member_use_from_same_package: ignore
|
deprecated_member_use_from_same_package: ignore
|
|
@ -463,7 +463,7 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose}
|
///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose}
|
||||||
///Disposes the channel.
|
///Disposes the channel and event handler.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
|
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
|
||||||
|
|
||||||
import '../types/in_app_webview_rect.dart';
|
import '../types/in_app_webview_rect.dart';
|
||||||
|
|
|
@ -209,17 +209,6 @@ abstract class InAppWebViewPlatform extends PlatformInterface {
|
||||||
'createPlatformWebStorage is not implemented on the current platform.');
|
'createPlatformWebStorage is not implemented on the current platform.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [PlatformStorage].
|
|
||||||
///
|
|
||||||
/// This function should only be called by the app-facing package.
|
|
||||||
/// Look at using [Storage] in `flutter_inappwebview` instead.
|
|
||||||
PlatformStorage createPlatformStorage(
|
|
||||||
PlatformStorageCreationParams params,
|
|
||||||
) {
|
|
||||||
throw UnimplementedError(
|
|
||||||
'createPlatformStorage is not implemented on the current platform.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new [PlatformLocalStorage].
|
/// Creates a new [PlatformLocalStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
|
@ -349,17 +338,6 @@ abstract class InAppWebViewPlatform extends PlatformInterface {
|
||||||
'createPlatformTracingController is not implemented on the current platform.');
|
'createPlatformTracingController is not implemented on the current platform.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [PlatformPathHandler].
|
|
||||||
///
|
|
||||||
/// This function should only be called by the app-facing package.
|
|
||||||
/// Look at using [PathHandler] in `flutter_inappwebview` instead.
|
|
||||||
PlatformPathHandler createPlatformPathHandler(
|
|
||||||
PlatformPathHandlerCreationParams params,
|
|
||||||
) {
|
|
||||||
throw UnimplementedError(
|
|
||||||
'createPlatformPathHandler is not implemented on the current platform.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new [PlatformAssetsPathHandler].
|
/// Creates a new [PlatformAssetsPathHandler].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
|
|
|
@ -36,28 +36,11 @@ class WebViewAssetLoader_ {
|
||||||
///
|
///
|
||||||
///[WebViewAssetLoader] will try Path Handlers in the order they're registered,
|
///[WebViewAssetLoader] will try Path Handlers in the order they're registered,
|
||||||
///and will use whichever is the first to return a non-null.
|
///and will use whichever is the first to return a non-null.
|
||||||
List<IPathHandler>? pathHandlers;
|
List<PlatformPathHandler>? pathHandlers;
|
||||||
|
|
||||||
WebViewAssetLoader_({this.domain, this.httpAllowed, this.pathHandlers});
|
WebViewAssetLoader_({this.domain, this.httpAllowed, this.pathHandlers});
|
||||||
}
|
}
|
||||||
|
|
||||||
///[PlatformPathHandler] interface.
|
|
||||||
abstract class IPathHandler {
|
|
||||||
String get path {
|
|
||||||
throw UnimplementedError('path is not implemented on the current platform');
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
|
||||||
throw UnimplementedError(
|
|
||||||
'toMap is not implemented on the current platform');
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
throw UnimplementedError(
|
|
||||||
'toJson is not implemented on the current platform');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [PlatformPathHandler].
|
/// Object specifying creation parameters for creating a [PlatformPathHandler].
|
||||||
///
|
///
|
||||||
/// Platform specific implementations can add additional fields by extending
|
/// Platform specific implementations can add additional fields by extending
|
||||||
|
@ -76,45 +59,25 @@ class PlatformPathHandlerCreationParams {
|
||||||
///
|
///
|
||||||
///Implement this interface to handle other use-cases according to your app's needs.
|
///Implement this interface to handle other use-cases according to your app's needs.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformPathHandler extends PlatformInterface
|
abstract class PlatformPathHandler {
|
||||||
implements IPathHandler {
|
|
||||||
/// Creates a new [PlatformWebViewAssetLoader]
|
|
||||||
factory PlatformPathHandler(PlatformPathHandlerCreationParams params) {
|
|
||||||
assert(
|
|
||||||
InAppWebViewPlatform.instance != null,
|
|
||||||
'A platform implementation for `flutter_inappwebview` has not been set. Please '
|
|
||||||
'ensure that an implementation of `InAppWebViewPlatform` has been set to '
|
|
||||||
'`WebViewPlatform.instance` before use. For unit testing, '
|
|
||||||
'`WebViewPlatform.instance` can be set with your own test implementation.',
|
|
||||||
);
|
|
||||||
final PlatformPathHandler pathHandler =
|
|
||||||
InAppWebViewPlatform.instance!.createPlatformPathHandler(params);
|
|
||||||
PlatformInterface.verify(pathHandler, _token);
|
|
||||||
return pathHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Used by the platform implementation to create a new
|
|
||||||
/// [PlatformPathHandler].
|
|
||||||
///
|
|
||||||
/// Should only be used by platform implementations because they can't extend
|
|
||||||
/// a class that only contains a factory constructor.
|
|
||||||
@protected
|
|
||||||
PlatformPathHandler.implementation(this.params) : super(token: _token);
|
|
||||||
|
|
||||||
static final Object _token = Object();
|
|
||||||
|
|
||||||
/// The parameters used to initialize the [PlatformPathHandler].
|
|
||||||
final PlatformPathHandlerCreationParams params;
|
|
||||||
|
|
||||||
/// Event handler object that handles the [PlatformPathHandler] events.
|
/// Event handler object that handles the [PlatformPathHandler] events.
|
||||||
PlatformPathHandlerEvents? eventHandler;
|
late final PlatformPathHandlerEvents? eventHandler;
|
||||||
|
|
||||||
|
///{@template flutter_inappwebview_platform_interface.PlatformPathHandler.type}
|
||||||
|
///The path handler type.
|
||||||
|
///{@endtemplate}
|
||||||
|
String get type {
|
||||||
|
throw UnimplementedError('type is not implemented on the current platform');
|
||||||
|
}
|
||||||
|
|
||||||
///{@template flutter_inappwebview_platform_interface.PlatformPathHandler.path}
|
///{@template flutter_inappwebview_platform_interface.PlatformPathHandler.path}
|
||||||
///The suffix path to be handled.
|
///The suffix path to be handled.
|
||||||
///
|
///
|
||||||
///The path should start and end with a `"/"` and it shouldn't collide with a real web path.
|
///The path should start and end with a `"/"` and it shouldn't collide with a real web path.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
String get path => params.path;
|
String get path {
|
||||||
|
throw UnimplementedError('path is not implemented on the current platform');
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
throw UnimplementedError(
|
throw UnimplementedError(
|
||||||
|
@ -181,7 +144,7 @@ class PlatformAssetsPathHandlerCreationParams
|
||||||
///Developers should ensure that asset files are named using standard file extensions.
|
///Developers should ensure that asset files are named using standard file extensions.
|
||||||
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformAssetsPathHandler extends PlatformPathHandler {
|
abstract class PlatformAssetsPathHandler extends PlatformInterface implements PlatformPathHandler {
|
||||||
/// Creates a new [PlatformAssetsPathHandler]
|
/// Creates a new [PlatformAssetsPathHandler]
|
||||||
factory PlatformAssetsPathHandler(
|
factory PlatformAssetsPathHandler(
|
||||||
PlatformAssetsPathHandlerCreationParams params) {
|
PlatformAssetsPathHandlerCreationParams params) {
|
||||||
|
@ -203,16 +166,18 @@ abstract class PlatformAssetsPathHandler extends PlatformPathHandler {
|
||||||
/// Should only be used by platform implementations because they can't extend
|
/// Should only be used by platform implementations because they can't extend
|
||||||
/// a class that only contains a factory constructor.
|
/// a class that only contains a factory constructor.
|
||||||
@protected
|
@protected
|
||||||
PlatformAssetsPathHandler.implementation(
|
PlatformAssetsPathHandler.implementation(this.params) : super(token: _token);
|
||||||
PlatformPathHandlerCreationParams params)
|
|
||||||
: super.implementation(
|
|
||||||
params is PlatformAssetsPathHandlerCreationParams
|
|
||||||
? params
|
|
||||||
: PlatformAssetsPathHandlerCreationParams
|
|
||||||
.fromPlatformPathHandlerCreationParams(params),
|
|
||||||
);
|
|
||||||
|
|
||||||
static final Object _token = Object();
|
static final Object _token = Object();
|
||||||
|
|
||||||
|
/// The parameters used to initialize the [PlatformAssetsPathHandler].
|
||||||
|
final PlatformAssetsPathHandlerCreationParams params;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get type => 'AssetsPathHandler';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get path => params.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [PlatformResourcesPathHandler].
|
/// Object specifying creation parameters for creating a [PlatformResourcesPathHandler].
|
||||||
|
@ -251,7 +216,7 @@ class PlatformResourcesPathHandlerCreationParams
|
||||||
///Developers should ensure that asset files are named using standard file extensions.
|
///Developers should ensure that asset files are named using standard file extensions.
|
||||||
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformResourcesPathHandler extends PlatformPathHandler {
|
abstract class PlatformResourcesPathHandler extends PlatformInterface implements PlatformPathHandler {
|
||||||
/// Creates a new [PlatformResourcesPathHandler]
|
/// Creates a new [PlatformResourcesPathHandler]
|
||||||
factory PlatformResourcesPathHandler(
|
factory PlatformResourcesPathHandler(
|
||||||
PlatformResourcesPathHandlerCreationParams params) {
|
PlatformResourcesPathHandlerCreationParams params) {
|
||||||
|
@ -274,16 +239,18 @@ abstract class PlatformResourcesPathHandler extends PlatformPathHandler {
|
||||||
/// Should only be used by platform implementations because they can't extend
|
/// Should only be used by platform implementations because they can't extend
|
||||||
/// a class that only contains a factory constructor.
|
/// a class that only contains a factory constructor.
|
||||||
@protected
|
@protected
|
||||||
PlatformResourcesPathHandler.implementation(
|
PlatformResourcesPathHandler.implementation(this.params) : super(token: _token);
|
||||||
PlatformPathHandlerCreationParams params)
|
|
||||||
: super.implementation(
|
|
||||||
params is PlatformResourcesPathHandlerCreationParams
|
|
||||||
? params
|
|
||||||
: PlatformResourcesPathHandlerCreationParams
|
|
||||||
.fromPlatformPathHandlerCreationParams(params),
|
|
||||||
);
|
|
||||||
|
|
||||||
static final Object _token = Object();
|
static final Object _token = Object();
|
||||||
|
|
||||||
|
/// The parameters used to initialize the [PlatformResourcesPathHandler].
|
||||||
|
final PlatformResourcesPathHandlerCreationParams params;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get type => 'ResourcesPathHandler';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get path => params.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [PlatformInternalStoragePathHandler].
|
/// Object specifying creation parameters for creating a [PlatformInternalStoragePathHandler].
|
||||||
|
@ -332,7 +299,7 @@ class PlatformInternalStoragePathHandlerCreationParams
|
||||||
///Developers should ensure that asset files are named using standard file extensions.
|
///Developers should ensure that asset files are named using standard file extensions.
|
||||||
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
///If the file does not have a recognised extension, `text/plain` will be used by default.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformInternalStoragePathHandler extends PlatformPathHandler {
|
abstract class PlatformInternalStoragePathHandler extends PlatformInterface implements PlatformPathHandler {
|
||||||
/// Creates a new [PlatformResourcesPathHandler]
|
/// Creates a new [PlatformResourcesPathHandler]
|
||||||
factory PlatformInternalStoragePathHandler(
|
factory PlatformInternalStoragePathHandler(
|
||||||
PlatformInternalStoragePathHandlerCreationParams params) {
|
PlatformInternalStoragePathHandlerCreationParams params) {
|
||||||
|
@ -355,21 +322,18 @@ abstract class PlatformInternalStoragePathHandler extends PlatformPathHandler {
|
||||||
/// Should only be used by platform implementations because they can't extend
|
/// Should only be used by platform implementations because they can't extend
|
||||||
/// a class that only contains a factory constructor.
|
/// a class that only contains a factory constructor.
|
||||||
@protected
|
@protected
|
||||||
PlatformInternalStoragePathHandler.implementation(
|
PlatformInternalStoragePathHandler.implementation(this.params) : super(token: _token);
|
||||||
PlatformPathHandlerCreationParams params,
|
|
||||||
{required String directory})
|
|
||||||
: super.implementation(
|
|
||||||
params is PlatformInternalStoragePathHandlerCreationParams
|
|
||||||
? params
|
|
||||||
: PlatformInternalStoragePathHandlerCreationParams
|
|
||||||
.fromPlatformPathHandlerCreationParams(params,
|
|
||||||
directory: directory),
|
|
||||||
);
|
|
||||||
|
|
||||||
static final Object _token = Object();
|
static final Object _token = Object();
|
||||||
|
|
||||||
PlatformInternalStoragePathHandlerCreationParams get _internalParams =>
|
/// The parameters used to initialize the [PlatformInternalStoragePathHandler].
|
||||||
params as PlatformInternalStoragePathHandlerCreationParams;
|
final PlatformInternalStoragePathHandlerCreationParams params;
|
||||||
|
|
||||||
String get directory => _internalParams.directory;
|
@override
|
||||||
|
String get type => 'InternalStoragePathHandler';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get path => params.path;
|
||||||
|
|
||||||
|
String get directory => params.directory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class WebViewAssetLoader {
|
||||||
///
|
///
|
||||||
///[WebViewAssetLoader] will try Path Handlers in the order they're registered,
|
///[WebViewAssetLoader] will try Path Handlers in the order they're registered,
|
||||||
///and will use whichever is the first to return a non-null.
|
///and will use whichever is the first to return a non-null.
|
||||||
List<IPathHandler>? pathHandlers;
|
List<PlatformPathHandler>? pathHandlers;
|
||||||
WebViewAssetLoader({this.domain, this.httpAllowed, this.pathHandlers});
|
WebViewAssetLoader({this.domain, this.httpAllowed, this.pathHandlers});
|
||||||
|
|
||||||
///Gets a possible [WebViewAssetLoader] instance from a [Map] value.
|
///Gets a possible [WebViewAssetLoader] instance from a [Map] value.
|
||||||
|
@ -46,7 +46,7 @@ class WebViewAssetLoader {
|
||||||
domain: map['domain'],
|
domain: map['domain'],
|
||||||
httpAllowed: map['httpAllowed'],
|
httpAllowed: map['httpAllowed'],
|
||||||
pathHandlers: map['pathHandlers'] != null
|
pathHandlers: map['pathHandlers'] != null
|
||||||
? List<IPathHandler>.from(map['pathHandlers'].map((e) => e))
|
? List<PlatformPathHandler>.from(map['pathHandlers'].map((e) => e))
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
|
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
|
||||||
|
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
|
@ -89,7 +89,11 @@ abstract class PlatformWebStorage extends PlatformInterface
|
||||||
@immutable
|
@immutable
|
||||||
class PlatformStorageCreationParams {
|
class PlatformStorageCreationParams {
|
||||||
/// Used by the platform implementation to create a new [PlatformStorage].
|
/// Used by the platform implementation to create a new [PlatformStorage].
|
||||||
const PlatformStorageCreationParams({required this.webStorageType});
|
const PlatformStorageCreationParams(
|
||||||
|
{required this.controller, required this.webStorageType});
|
||||||
|
|
||||||
|
///{@macro flutter_inappwebview_platform_interface.PlatformStorage.controller}
|
||||||
|
final PlatformInAppWebViewController? controller;
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformStorage.webStorageType}
|
///{@macro flutter_inappwebview_platform_interface.PlatformStorage.webStorageType}
|
||||||
final WebStorageType webStorageType;
|
final WebStorageType webStorageType;
|
||||||
|
@ -99,38 +103,19 @@ class PlatformStorageCreationParams {
|
||||||
///Class that provides methods to manage the JavaScript [Storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) object.
|
///Class that provides methods to manage the JavaScript [Storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) object.
|
||||||
///It is used by [PlatformLocalStorage] and [PlatformSessionStorage].
|
///It is used by [PlatformLocalStorage] and [PlatformSessionStorage].
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformStorage extends PlatformInterface implements Disposable {
|
abstract class PlatformStorage implements Disposable {
|
||||||
/// Creates a new [PlatformStorage]
|
///{@template flutter_inappwebview_platform_interface.PlatformStorage.controller}
|
||||||
factory PlatformStorage(PlatformStorageCreationParams params) {
|
///Controller used to interact with storage.
|
||||||
assert(
|
///{@endtemplate}
|
||||||
InAppWebViewPlatform.instance != null,
|
PlatformInAppWebViewController? get controller;
|
||||||
'A platform implementation for `flutter_inappwebview` has not been set. Please '
|
|
||||||
'ensure that an implementation of `InAppWebViewPlatform` has been set to '
|
|
||||||
'`InAppWebViewPlatform.instance` before use. For unit testing, '
|
|
||||||
'`InAppWebViewPlatform.instance` can be set with your own test implementation.',
|
|
||||||
);
|
|
||||||
final PlatformStorage storage =
|
|
||||||
InAppWebViewPlatform.instance!.createPlatformStorage(params);
|
|
||||||
PlatformInterface.verify(storage, _token);
|
|
||||||
return storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Used by the platform implementation to create a new [PlatformStorage].
|
|
||||||
///
|
|
||||||
/// Should only be used by platform implementations because they can't extend
|
|
||||||
/// a class that only contains a factory constructor.
|
|
||||||
@protected
|
|
||||||
PlatformStorage.implementation(this.params) : super(token: _token);
|
|
||||||
|
|
||||||
static final Object _token = Object();
|
|
||||||
|
|
||||||
/// The parameters used to initialize the [PlatformStorage].
|
|
||||||
final PlatformStorageCreationParams params;
|
|
||||||
|
|
||||||
///{@template flutter_inappwebview_platform_interface.PlatformStorage.webStorageType}
|
///{@template flutter_inappwebview_platform_interface.PlatformStorage.webStorageType}
|
||||||
///The web storage type: `window.sessionStorage` or `window.localStorage`.
|
///The web storage type: `window.sessionStorage` or `window.localStorage`.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
WebStorageType get webStorageType => params.webStorageType;
|
WebStorageType get webStorageType {
|
||||||
|
throw UnimplementedError(
|
||||||
|
'webStorageType is not implemented on the current platform');
|
||||||
|
}
|
||||||
|
|
||||||
///{@template flutter_inappwebview_platform_interface.PlatformStorage.length}
|
///{@template flutter_inappwebview_platform_interface.PlatformStorage.length}
|
||||||
///Returns an integer representing the number of data items stored in the Storage object.
|
///Returns an integer representing the number of data items stored in the Storage object.
|
||||||
|
@ -251,11 +236,13 @@ abstract class PlatformStorage extends PlatformInterface implements Disposable {
|
||||||
@immutable
|
@immutable
|
||||||
class PlatformLocalStorageCreationParams extends PlatformStorageCreationParams {
|
class PlatformLocalStorageCreationParams extends PlatformStorageCreationParams {
|
||||||
/// Used by the platform implementation to create a new [PlatformLocalStorage].
|
/// Used by the platform implementation to create a new [PlatformLocalStorage].
|
||||||
const PlatformLocalStorageCreationParams(
|
PlatformLocalStorageCreationParams(
|
||||||
// This parameter prevents breaking changes later.
|
// This parameter prevents breaking changes later.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformStorageCreationParams params,
|
PlatformStorageCreationParams params,
|
||||||
) : super(webStorageType: WebStorageType.LOCAL_STORAGE);
|
) : super(
|
||||||
|
controller: params.controller,
|
||||||
|
webStorageType: WebStorageType.LOCAL_STORAGE);
|
||||||
|
|
||||||
/// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams].
|
/// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams].
|
||||||
factory PlatformLocalStorageCreationParams.fromPlatformStorageCreationParams(
|
factory PlatformLocalStorageCreationParams.fromPlatformStorageCreationParams(
|
||||||
|
@ -268,7 +255,8 @@ class PlatformLocalStorageCreationParams extends PlatformStorageCreationParams {
|
||||||
///Class that provides methods to manage the JavaScript `window.localStorage` object.
|
///Class that provides methods to manage the JavaScript `window.localStorage` object.
|
||||||
///It used by [PlatformWebStorage].
|
///It used by [PlatformWebStorage].
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformLocalStorage extends PlatformStorage {
|
abstract class PlatformLocalStorage extends PlatformInterface
|
||||||
|
with PlatformStorage {
|
||||||
/// Creates a new [PlatformLocalStorage]
|
/// Creates a new [PlatformLocalStorage]
|
||||||
factory PlatformLocalStorage(PlatformLocalStorageCreationParams params) {
|
factory PlatformLocalStorage(PlatformLocalStorageCreationParams params) {
|
||||||
assert(
|
assert(
|
||||||
|
@ -289,15 +277,15 @@ abstract class PlatformLocalStorage extends PlatformStorage {
|
||||||
/// Should only be used by platform implementations because they can't extend
|
/// Should only be used by platform implementations because they can't extend
|
||||||
/// a class that only contains a factory constructor.
|
/// a class that only contains a factory constructor.
|
||||||
@protected
|
@protected
|
||||||
PlatformLocalStorage.implementation(PlatformStorageCreationParams params)
|
PlatformLocalStorage.implementation(this.params) : super(token: _token);
|
||||||
: super.implementation(
|
|
||||||
params is PlatformLocalStorageCreationParams
|
|
||||||
? params
|
|
||||||
: PlatformLocalStorageCreationParams
|
|
||||||
.fromPlatformStorageCreationParams(params),
|
|
||||||
);
|
|
||||||
|
|
||||||
static final Object _token = Object();
|
static final Object _token = Object();
|
||||||
|
|
||||||
|
/// The parameters used to initialize the [PlatformLocalStorage].
|
||||||
|
final PlatformLocalStorageCreationParams params;
|
||||||
|
|
||||||
|
@override
|
||||||
|
WebStorageType get webStorageType => params.webStorageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [PlatformSessionStorage].
|
/// Object specifying creation parameters for creating a [PlatformSessionStorage].
|
||||||
|
@ -308,11 +296,13 @@ abstract class PlatformLocalStorage extends PlatformStorage {
|
||||||
class PlatformSessionStorageCreationParams
|
class PlatformSessionStorageCreationParams
|
||||||
extends PlatformStorageCreationParams {
|
extends PlatformStorageCreationParams {
|
||||||
/// Used by the platform implementation to create a new [PlatformSessionStorage].
|
/// Used by the platform implementation to create a new [PlatformSessionStorage].
|
||||||
const PlatformSessionStorageCreationParams(
|
PlatformSessionStorageCreationParams(
|
||||||
// This parameter prevents breaking changes later.
|
// This parameter prevents breaking changes later.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformStorageCreationParams params,
|
PlatformStorageCreationParams params,
|
||||||
) : super(webStorageType: WebStorageType.SESSION_STORAGE);
|
) : super(
|
||||||
|
controller: params.controller,
|
||||||
|
webStorageType: WebStorageType.SESSION_STORAGE);
|
||||||
|
|
||||||
/// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams].
|
/// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams].
|
||||||
factory PlatformSessionStorageCreationParams.fromPlatformStorageCreationParams(
|
factory PlatformSessionStorageCreationParams.fromPlatformStorageCreationParams(
|
||||||
|
@ -325,7 +315,8 @@ class PlatformSessionStorageCreationParams
|
||||||
///Class that provides methods to manage the JavaScript `window.sessionStorage` object.
|
///Class that provides methods to manage the JavaScript `window.sessionStorage` object.
|
||||||
///It used by [PlatformWebStorage].
|
///It used by [PlatformWebStorage].
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformSessionStorage extends PlatformStorage {
|
abstract class PlatformSessionStorage extends PlatformInterface
|
||||||
|
with PlatformStorage {
|
||||||
/// Creates a new [PlatformSessionStorage]
|
/// Creates a new [PlatformSessionStorage]
|
||||||
factory PlatformSessionStorage(PlatformSessionStorageCreationParams params) {
|
factory PlatformSessionStorage(PlatformSessionStorageCreationParams params) {
|
||||||
assert(
|
assert(
|
||||||
|
@ -346,13 +337,13 @@ abstract class PlatformSessionStorage extends PlatformStorage {
|
||||||
/// Should only be used by platform implementations because they can't extend
|
/// Should only be used by platform implementations because they can't extend
|
||||||
/// a class that only contains a factory constructor.
|
/// a class that only contains a factory constructor.
|
||||||
@protected
|
@protected
|
||||||
PlatformSessionStorage.implementation(PlatformStorageCreationParams params)
|
PlatformSessionStorage.implementation(this.params) : super(token: _token);
|
||||||
: super.implementation(
|
|
||||||
params is PlatformSessionStorageCreationParams
|
|
||||||
? params
|
|
||||||
: PlatformSessionStorageCreationParams
|
|
||||||
.fromPlatformStorageCreationParams(params),
|
|
||||||
);
|
|
||||||
|
|
||||||
static final Object _token = Object();
|
static final Object _token = Object();
|
||||||
|
|
||||||
|
/// The parameters used to initialize the [PlatformSessionStorage].
|
||||||
|
final PlatformSessionStorageCreationParams params;
|
||||||
|
|
||||||
|
@override
|
||||||
|
WebStorageType get webStorageType => params.webStorageType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'dart:async';
|
||||||
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
||||||
|
|
||||||
import 'in_app_webview/in_app_webview_controller.dart';
|
import 'in_app_webview/in_app_webview_controller.dart';
|
||||||
import 'in_app_webview/headless_in_app_webview.dart';
|
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager}
|
///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager}
|
||||||
class CookieManager {
|
class CookieManager {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import '../find_interaction/find_interaction_controller.dart';
|
||||||
import '../pull_to_refresh/main.dart';
|
import '../pull_to_refresh/main.dart';
|
||||||
|
|
||||||
import '../in_app_webview/in_app_webview_controller.dart';
|
import '../in_app_webview/in_app_webview_controller.dart';
|
||||||
import '../print_job/main.dart';
|
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser}
|
///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser}
|
||||||
class InAppBrowser implements PlatformInAppBrowserEvents {
|
class InAppBrowser implements PlatformInAppBrowserEvents {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
||||||
|
|
||||||
|
import '../in_app_webview/in_app_webview_controller.dart';
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage}
|
||||||
class WebStorage {
|
class WebStorage {
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage}
|
||||||
|
@ -37,27 +39,16 @@ class WebStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
|
||||||
class Storage {
|
abstract class Storage implements PlatformStorage {
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
|
|
||||||
Storage({required WebStorageType webStorageType})
|
|
||||||
: this.fromPlatformCreationParams(
|
|
||||||
params:
|
|
||||||
PlatformStorageCreationParams(webStorageType: webStorageType));
|
|
||||||
|
|
||||||
/// Constructs a [Storage].
|
|
||||||
///
|
|
||||||
/// See [Storage.fromPlatformCreationParams] for setting parameters for
|
|
||||||
/// a specific platform.
|
|
||||||
Storage.fromPlatformCreationParams({
|
|
||||||
required PlatformStorageCreationParams params,
|
|
||||||
}) : this.fromPlatform(platform: PlatformStorage(params));
|
|
||||||
|
|
||||||
/// Constructs a [Storage] from a specific platform implementation.
|
/// Constructs a [Storage] from a specific platform implementation.
|
||||||
Storage.fromPlatform({required this.platform});
|
Storage.fromPlatform({required this.platform});
|
||||||
|
|
||||||
/// Implementation of [PlatformStorage] for the current platform.
|
/// Implementation of [PlatformStorage] for the current platform.
|
||||||
final PlatformStorage platform;
|
final PlatformStorage platform;
|
||||||
|
|
||||||
|
///{@macro flutter_inappwebview_platform_interface.PlatformStorage.controller}
|
||||||
|
PlatformInAppWebViewController? get controller => platform.controller;
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformStorage.webStorageType}
|
///{@macro flutter_inappwebview_platform_interface.PlatformStorage.webStorageType}
|
||||||
WebStorageType get webStorageType => platform.webStorageType;
|
WebStorageType get webStorageType => platform.webStorageType;
|
||||||
|
|
||||||
|
@ -91,10 +82,11 @@ class Storage {
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
||||||
class LocalStorage extends Storage {
|
class LocalStorage extends Storage {
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
||||||
LocalStorage()
|
LocalStorage({required InAppWebViewController? controller})
|
||||||
: this.fromPlatformCreationParams(
|
: this.fromPlatformCreationParams(
|
||||||
params: PlatformLocalStorageCreationParams(
|
params: PlatformLocalStorageCreationParams(
|
||||||
PlatformStorageCreationParams(
|
PlatformStorageCreationParams(
|
||||||
|
controller: controller?.platform,
|
||||||
webStorageType: WebStorageType.LOCAL_STORAGE)));
|
webStorageType: WebStorageType.LOCAL_STORAGE)));
|
||||||
|
|
||||||
/// Constructs a [LocalStorage].
|
/// Constructs a [LocalStorage].
|
||||||
|
@ -116,10 +108,11 @@ class LocalStorage extends Storage {
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
||||||
class SessionStorage extends Storage {
|
class SessionStorage extends Storage {
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
||||||
SessionStorage()
|
SessionStorage({required InAppWebViewController? controller})
|
||||||
: this.fromPlatformCreationParams(
|
: this.fromPlatformCreationParams(
|
||||||
params: PlatformSessionStorageCreationParams(
|
params: PlatformSessionStorageCreationParams(
|
||||||
PlatformStorageCreationParams(
|
PlatformStorageCreationParams(
|
||||||
|
controller: controller?.platform,
|
||||||
webStorageType: WebStorageType.SESSION_STORAGE)));
|
webStorageType: WebStorageType.SESSION_STORAGE)));
|
||||||
|
|
||||||
/// Constructs a [SessionStorage].
|
/// Constructs a [SessionStorage].
|
||||||
|
|
|
@ -1,32 +1,26 @@
|
||||||
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler}
|
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler}
|
||||||
abstract class PathHandler implements IPathHandler, PlatformPathHandlerEvents {
|
abstract class PathHandler
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler}
|
implements PlatformPathHandler, PlatformPathHandlerEvents {
|
||||||
PathHandler({required String path})
|
|
||||||
: this.fromPlatformCreationParams(
|
|
||||||
params: PlatformPathHandlerCreationParams(path: path));
|
|
||||||
|
|
||||||
/// Constructs a [PathHandler].
|
|
||||||
///
|
|
||||||
/// See [PathHandler.fromPlatformCreationParams] for setting parameters for
|
|
||||||
/// a specific platform.
|
|
||||||
PathHandler.fromPlatformCreationParams({
|
|
||||||
required PlatformPathHandlerCreationParams params,
|
|
||||||
}) : this.fromPlatform(platform: PlatformPathHandler(params));
|
|
||||||
|
|
||||||
/// Constructs a [PathHandler] from a specific platform implementation.
|
/// Constructs a [PathHandler] from a specific platform implementation.
|
||||||
PathHandler.fromPlatform({required this.platform}) {
|
PathHandler.fromPlatform({required this.platform}) {
|
||||||
this.platform.eventHandler = this;
|
this.platform.eventHandler = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
late final PlatformPathHandlerEvents? eventHandler;
|
||||||
|
|
||||||
/// Implementation of [PlatformPathHandler] for the current platform.
|
/// Implementation of [PlatformPathHandler] for the current platform.
|
||||||
final PlatformPathHandler platform;
|
final PlatformPathHandler platform;
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler.path}
|
@override
|
||||||
|
String get type => platform.type;
|
||||||
|
|
||||||
|
@override
|
||||||
String get path => platform.path;
|
String get path => platform.path;
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler.handle}
|
@override
|
||||||
Future<WebResourceResponse?> handle(String path) async {
|
Future<WebResourceResponse?> handle(String path) async {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ app.get("/echo-headers", (req, res) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/test-index', (req, res) => {
|
app.get('/test-index', (req, res) => {
|
||||||
res.sendFile(__dirname + '/public/index.html');
|
res.sendFile(__dirname + '/public/test-index.html');
|
||||||
})
|
})
|
||||||
|
|
||||||
app.post("/test-post", (req, res) => {
|
app.post("/test-post", (req, res) => {
|
||||||
|
|
Loading…
Reference in New Issue