iosWebViewFix/flutter_inappwebview/lib/src/webview_asset_loader.dart

109 lines
4.3 KiB
Dart
Raw Normal View History

2023-11-17 22:28:11 +00:00
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
2023-11-24 16:56:57 +00:00
///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler}
abstract class PathHandler
implements PlatformPathHandler, PlatformPathHandlerEvents {
2023-11-17 22:28:11 +00:00
/// Constructs a [PathHandler] from a specific platform implementation.
PathHandler.fromPlatform({required this.platform}) {
this.platform.eventHandler = this;
}
@override
late final PlatformPathHandlerEvents? eventHandler;
2023-11-17 22:28:11 +00:00
/// Implementation of [PlatformPathHandler] for the current platform.
final PlatformPathHandler platform;
@override
String get type => platform.type;
@override
2023-11-17 22:28:11 +00:00
String get path => platform.path;
@override
Future<WebResourceResponse?> handle(String path) async {
return null;
}
@override
Map<String, dynamic> toMap() => platform.toMap();
@override
Map<String, dynamic> toJson() => platform.toJson();
}
2023-11-24 16:56:57 +00:00
///{@macro flutter_inappwebview_platform_interface.PlatformAssetsPathHandler}
class AssetsPathHandler extends PathHandler {
2023-11-24 16:56:57 +00:00
///{@macro flutter_inappwebview_platform_interface.PlatformAssetsPathHandler}
2023-11-17 22:28:11 +00:00
AssetsPathHandler({required String path})
: this.fromPlatformCreationParams(
params: PlatformAssetsPathHandlerCreationParams(
PlatformPathHandlerCreationParams(path: path)));
/// Constructs a [AssetsPathHandler].
///
/// See [AssetsPathHandler.fromPlatformCreationParams] for setting parameters for
/// a specific platform.
AssetsPathHandler.fromPlatformCreationParams({
required PlatformAssetsPathHandlerCreationParams params,
}) : this.fromPlatform(platform: PlatformAssetsPathHandler(params));
/// Constructs a [AssetsPathHandler] from a specific platform implementation.
AssetsPathHandler.fromPlatform({required this.platform})
: super.fromPlatform(platform: platform);
/// Implementation of [PlatformAssetsPathHandler] for the current platform.
final PlatformAssetsPathHandler platform;
}
2023-11-24 16:56:57 +00:00
///{@macro flutter_inappwebview_platform_interface.PlatformResourcesPathHandler}
class ResourcesPathHandler extends PathHandler {
2023-11-24 16:56:57 +00:00
///{@macro flutter_inappwebview_platform_interface.PlatformResourcesPathHandler}
2023-11-17 22:28:11 +00:00
ResourcesPathHandler({required String path})
: this.fromPlatformCreationParams(
params: PlatformResourcesPathHandlerCreationParams(
PlatformPathHandlerCreationParams(path: path)));
2023-11-17 22:28:11 +00:00
/// Constructs a [ResourcesPathHandler].
///
/// See [ResourcesPathHandler.fromPlatformCreationParams] for setting parameters for
/// a specific platform.
ResourcesPathHandler.fromPlatformCreationParams({
required PlatformResourcesPathHandlerCreationParams params,
}) : this.fromPlatform(platform: PlatformResourcesPathHandler(params));
/// Constructs a [ResourcesPathHandler] from a specific platform implementation.
ResourcesPathHandler.fromPlatform({required this.platform})
: super.fromPlatform(platform: platform);
/// Implementation of [PlatformResourcesPathHandler] for the current platform.
final PlatformResourcesPathHandler platform;
}
2023-11-24 16:56:57 +00:00
///{@macro flutter_inappwebview_platform_interface.PlatformInternalStoragePathHandler}
class InternalStoragePathHandler extends PathHandler {
2023-11-24 16:56:57 +00:00
///{@macro flutter_inappwebview_platform_interface.PlatformInternalStoragePathHandler}
2023-11-17 22:28:11 +00:00
InternalStoragePathHandler({required String path, required String directory})
: this.fromPlatformCreationParams(
params: PlatformInternalStoragePathHandlerCreationParams(
PlatformPathHandlerCreationParams(path: path),
directory: directory));
2023-11-17 22:28:11 +00:00
/// Constructs a [InternalStoragePathHandler].
///
/// See [InternalStoragePathHandler.fromPlatformCreationParams] for setting parameters for
/// a specific platform.
InternalStoragePathHandler.fromPlatformCreationParams({
required PlatformInternalStoragePathHandlerCreationParams params,
}) : this.fromPlatform(platform: PlatformInternalStoragePathHandler(params));
2023-11-17 22:28:11 +00:00
/// Constructs a [InternalStoragePathHandler] from a specific platform implementation.
InternalStoragePathHandler.fromPlatform({required this.platform})
: super.fromPlatform(platform: platform);
2023-11-17 22:28:11 +00:00
/// Implementation of [PlatformInternalStoragePathHandler] for the current platform.
final PlatformInternalStoragePathHandler platform;
2023-11-17 22:28:11 +00:00
String get directory => platform.directory;
}