onDownloadStarting property
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.setDownloadListener', apiUrl: '(https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)'), IOSPlatform(), MacOSPlatform(), WindowsPlatform(apiName: 'ICoreWebView2_4.add_DownloadStarting', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_4?view=webview2-1.0.2849.39#add_downloadstarting'), LinuxPlatform(apiName: 'WebKitWebView::decide-policy', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/signal.WebView.decide-policy.html', note: 'Downloads are detected via WEBKIT_POLICY_DECISION_TYPE_RESPONSE.')])
final
Event fired when WebView recognizes a downloadable file.
To download the file, you can use the flutter_downloader plugin.
downloadStartRequest represents the request of the file to download.
NOTE: In order to be able to listen this event, check the InAppWebViewSettings.useOnDownloadStart setting documentation.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebView.setDownloadListener
- iOS WKWebView
- macOS WKWebView
- Windows WebView2 (Official API - ICoreWebView2_4.add_DownloadStarting)
- Linux WPE WebKit (Official API - WebKitWebView::decide-policy):
- Downloads are detected via WEBKIT_POLICY_DECISION_TYPE_RESPONSE.
Parameters - Officially Supported Platforms/Implementations:
downloadStartRequest: all platforms
Use the PlatformWebViewCreationParams.isPropertySupported method to check if this property is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'WebView.setDownloadListener',
apiUrl:
'(https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)',
),
IOSPlatform(),
MacOSPlatform(),
WindowsPlatform(
apiName: 'ICoreWebView2_4.add_DownloadStarting',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_4?view=webview2-1.0.2849.39#add_downloadstarting',
),
LinuxPlatform(
apiName: 'WebKitWebView::decide-policy',
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/signal.WebView.decide-policy.html',
note:
'Downloads are detected via WEBKIT_POLICY_DECISION_TYPE_RESPONSE.',
),
],
)
final FutureOr<DownloadStartResponse?> Function(
T controller,
DownloadStartRequest downloadStartRequest,
)?
onDownloadStarting;