Skip to content
WebView AllWebView All
Documentation for version 1.2.x; select latest for up-to-date APIs.

Common API

Import:

import 'package:webview_all/webview_all.dart';

Constructors:

ConstructorUse
WebViewController({onPermissionRequest})Creates a controller using generic platform params.
WebViewController.fromPlatformCreationParams(params, {onPermissionRequest})Creates a controller with platform-specific creation params.
WebViewController.fromPlatform(platform, {onPermissionRequest})Wraps an existing PlatformWebViewController.

Properties:

PropertyTypeUse
platformPlatformWebViewControllerUnderlying platform controller. Cast to platform-specific classes after checking type.

Loading:

MethodReturnUse
loadRequest(Uri uri, {LoadRequestMethod method, Map<String, String> headers, Uint8List? body})Future<void>Loads a URL or HTTP request.
loadFile(String absoluteFilePath)Future<void>Loads a device file.
loadFlutterAsset(String key)Future<void>Loads a Flutter asset.
loadHtmlString(String html, {String? baseUrl})Future<void>Loads in-memory HTML.

Navigation:

MethodReturn
currentUrl()Future<String?>
canGoBack()Future<bool>
canGoForward()Future<bool>
goBack()Future<void>
goForward()Future<void>
reload()Future<void>
setNavigationDelegate(NavigationDelegate delegate)Future<void>

Storage:

MethodReturn
clearCache()Future<void>
clearLocalStorage()Future<void>

JavaScript:

MethodReturn
setJavaScriptMode(JavaScriptMode javaScriptMode)Future<void>
runJavaScript(String javaScript)Future<void>
runJavaScriptReturningResult(String javaScript)Future<Object>
addJavaScriptChannel(String name, {required void Function(JavaScriptMessage) onMessageReceived})Future<void>
removeJavaScriptChannel(String name)Future<void>
setOnConsoleMessage(callback)Future<void>
setOnJavaScriptAlertDialog(callback)Future<void>
setOnJavaScriptConfirmDialog(callback)Future<void>
setOnJavaScriptTextInputDialog(callback)Future<void>

View state:

MethodReturn
getTitle()Future<String?>
scrollTo(int x, int y)Future<void>
scrollBy(int x, int y)Future<void>
getScrollPosition()Future<Offset>
setOnScrollPositionChange(callback?)Future<void>
setVerticalScrollBarEnabled(bool enabled)Future<void>
setHorizontalScrollBarEnabled(bool enabled)Future<void>
supportsSetScrollBarsEnabled()Future<bool>
enableZoom(bool enabled)Future<void>
setBackgroundColor(Color color)Future<void>
setUserAgent(String? userAgent)Future<void>
getUserAgent()Future<String?>
setOverScrollMode(WebViewOverScrollMode mode)Future<void>

Constructors:

ConstructorUse
NavigationDelegate({...callbacks})Creates a delegate with common params.
NavigationDelegate.fromPlatformCreationParams(params, {...callbacks})Uses platform-specific delegate params.
NavigationDelegate.fromPlatform(platform, {...callbacks})Wraps an existing platform delegate.

Callbacks:

CallbackSignatureUse
onNavigationRequestFutureOr<NavigationDecision> Function(NavigationRequest)Allow or block navigation.
onPageStartedvoid Function(String url)Main-frame load started.
onPageFinishedvoid Function(String url)Main-frame load finished.
onProgressvoid Function(int progress)Load progress.
onWebResourceErrorvoid Function(WebResourceError error)Resource load error.
onUrlChangevoid Function(UrlChange change)URL changed.
onHttpAuthRequestvoid Function(HttpAuthRequest request)HTTP auth challenge.
onHttpErrorvoid Function(HttpResponseError error)HTTP status error.
onSslAuthErrorvoid Function(SslAuthError request)Recoverable SSL certificate error.
MemberUse
platformUnderlying PlatformSslAuthError.
certificateCertificate where the engine provides one.
cancel()Cancels the request. Use this by default in production.
proceed()Continues despite the TLS error. Use only in controlled test environments.

Constructors:

ConstructorUse
WebViewWidget({controller, layoutDirection, gestureRecognizers})Builds the current platform WebView.
WebViewWidget.fromPlatformCreationParams({params})Builds with platform-specific widget params.
WebViewWidget.fromPlatform({platform})Wraps an existing platform widget.

The widget delegates build to the active platform implementation.

Constructors:

ConstructorUse
WebViewCookieManager()Creates a common cookie manager.
WebViewCookieManager.fromPlatformCreationParams(params)Uses platform cookie params.
WebViewCookieManager.fromPlatform(platform)Wraps an existing platform cookie manager.

Methods:

MethodReturnUse
clearCookies()Future<bool>Clears cookies.
setCookie(WebViewCookie cookie)Future<void>Sets a common cookie.
getCookies({required Uri domain})Future<List<WebViewCookie>>Gets cookies visible for a domain.

webview_all.dart exports the platform interface types needed by app code, including:

  • LoadRequestMethod
  • NavigationDecision
  • NavigationRequest
  • WebResourceError
  • HttpResponseError
  • HttpAuthRequest
  • WebViewCredential
  • JavaScriptMode
  • JavaScriptMessage
  • JavaScriptConsoleMessage
  • JavaScriptAlertDialogRequest
  • JavaScriptConfirmDialogRequest
  • JavaScriptTextInputDialogRequest
  • ScrollPositionChange
  • WebViewCookie
  • WebViewOverScrollMode
  • WebViewPermissionResourceType
  • WebViewPlatform
  • platform creation params for controller, delegate, widget, and cookie manager