saveWebArchive method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.saveWebArchive', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)', note: 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension.'), IOSPlatform(available: '14.0', note: 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.'), LinuxPlatform(apiName: 'webkit_web_view_save_to_file', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.save_to_file.html', note: 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension.'), MacOSPlatform(available: '11.0', note: 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.')])
Saves the current WebView as a web archive.
Returns the file path under which the web archive file was saved, or null if saving the file failed.
filePath represents the file path where the archive should be placed. This value cannot be null.
autoname if false, takes filePath to be a file.
If true, filePath is assumed to be a directory in which a filename will be chosen according to the URL of the current page.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebView.saveWebArchive):
- If
autonameisfalse, thefilePathmust ends with the WebArchiveFormat.MHT file extension.
- If
- iOS WKWebView 14.0+:
- If
autonameisfalse, thefilePathmust ends with the WebArchiveFormat.WEBARCHIVE file extension.
- If
- Linux WPE WebKit (Official API - webkit_web_view_save_to_file):
- If
autonameisfalse, thefilePathmust ends with the WebArchiveFormat.MHT file extension.
- If
- macOS WKWebView 11.0+:
- If
autonameisfalse, thefilePathmust ends with the WebArchiveFormat.WEBARCHIVE file extension.
- If
Parameters - Officially Supported Platforms/Implementations:
filePath: all platformsautoname: all platforms
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'WebView.saveWebArchive',
apiUrl:
'https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)',
note:
'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension.',
),
IOSPlatform(
available: '14.0',
note:
'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.',
),
LinuxPlatform(
apiName: 'webkit_web_view_save_to_file',
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.save_to_file.html',
note:
'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension.',
),
MacOSPlatform(
available: '11.0',
note:
'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.',
),
],
)
Future<String?> saveWebArchive({
required String filePath,
bool autoname = false,
}) {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.saveWebArchive.name} is not implemented on the current platform',
);
}