NavigationDelegate.fromPlatformCreationParams constructor
NavigationDelegate.fromPlatformCreationParams(
- PlatformNavigationDelegateCreationParams params, {
- void onPageStarted(
- String url
- void onPageFinished(
- String url
- void onProgress(
- int progress
- void onWebResourceError(
- WebResourceError error
- void onUrlChange(
- UrlChange change
- void onHttpAuthRequest(
- HttpAuthRequest request
- void onHttpError(
- HttpResponseError error
Constructs a NavigationDelegate from creation params for a specific platform.
onUrlChange
: invoked when the underlying web view changes to a new url.
onHttpAuthRequest
: invoked when the web view is requesting authentication.
Below is an example of setting platform-specific creation parameters for iOS and Android:
PlatformNavigationDelegateCreationParams params =
const PlatformNavigationDelegateCreationParams();
if (WebViewPlatform.instance is WebKitWebViewPlatform) {
params = WebKitNavigationDelegateCreationParams
.fromPlatformNavigationDelegateCreationParams(
params,
);
} else if (WebViewPlatform.instance is AndroidWebViewPlatform) {
params = AndroidNavigationDelegateCreationParams
.fromPlatformNavigationDelegateCreationParams(
params,
);
}
final NavigationDelegate navigationDelegate =
NavigationDelegate.fromPlatformCreationParams(
params,
);
Implementation
NavigationDelegate.fromPlatformCreationParams(
PlatformNavigationDelegateCreationParams params, {
FutureOr<NavigationDecision> Function(NavigationRequest request)?
onNavigationRequest,
void Function(String url)? onPageStarted,
void Function(String url)? onPageFinished,
void Function(int progress)? onProgress,
void Function(WebResourceError error)? onWebResourceError,
void Function(UrlChange change)? onUrlChange,
void Function(HttpAuthRequest request)? onHttpAuthRequest,
void Function(HttpResponseError error)? onHttpError,
}) : this.fromPlatform(
PlatformNavigationDelegate(params),
onNavigationRequest: onNavigationRequest,
onPageStarted: onPageStarted,
onPageFinished: onPageFinished,
onProgress: onProgress,
onWebResourceError: onWebResourceError,
onUrlChange: onUrlChange,
onHttpAuthRequest: onHttpAuthRequest,
onHttpError: onHttpError,
);