launch method
Future<void>
launch(
- String url, {
- Map<
String, String> ? headers, - Set<
JavascriptChannel> javascriptChannels = const <JavascriptChannel>{}, - bool withJavascript = true,
- bool clearCache = false,
- bool clearCookies = false,
- bool mediaPlaybackRequiresUserGesture = true,
- bool enableAppScheme = true,
- Rect? rect,
- String? userAgent,
- bool withZoom = false,
- bool displayZoomControls = false,
- bool withLocalStorage = true,
- bool withLocalUrl = false,
- String? localUrlScope,
- bool withOverviewMode = false,
- bool scrollBar = true,
- bool supportMultipleWindows = false,
- bool appCacheEnabled = false,
- bool allowFileURLs = false,
- bool useWideViewPort = false,
- String? invalidUrlRegex,
- bool geolocationEnabled = false,
- bool debuggingEnabled = false,
- bool ignoreSSLErrors = false,
Start the Webview with url
headersspecify additional HTTP headerswithJavascriptenable Javascript or not for the WebviewclearCacheclear the cache of the WebviewclearCookiesclear all cookies of the Webviewhiddennot showrect: show in rect, fullscreen if nullenableAppScheme: false will enable all schemes, true only for httt/https/about android: Not implemented yetuserAgent: set the User-Agent of WebViewwithZoom: enable zoom on webviewwithLocalStorageenable localStorage API on Webview Currently Android only. It is always enabled in UIWebView of iOS and can not be disabled.withLocalUrl: allow url as a local path Allow local files on iOs > 9.0localUrlScope: allowed folder for local paths iOS only. If null and withLocalUrl is true, then it will use the url as the scope, allowing only itself to be read.scrollBar: enable or disable scrollbarsupportMultipleWindowsenable multiple windows support in AndroidinvalidUrlRegexis the regular expression of URLs that web view shouldn't load. For example, when webview is redirected to a specific URL, you want to intercept this process by stopping loading this URL and replacing webview by another screen. Android only settings:displayZoomControls: display zoom controls on webviewwithOverviewMode: enable overview mode for Android webview ( setLoadWithOverviewMode )useWideViewPort: use wide viewport for Android webview ( setUseWideViewPort )ignoreSSLErrors: use to bypass Android/iOS SSL checks e.g. for self-signed certificates
Implementation
Future<void> launch(
String url, {
Map<String, String>? headers,
Set<JavascriptChannel> javascriptChannels = const <JavascriptChannel>{},
bool withJavascript = true,
bool clearCache = false,
bool clearCookies = false,
bool mediaPlaybackRequiresUserGesture = true,
bool hidden = false,
bool enableAppScheme = true,
Rect? rect,
String? userAgent,
bool withZoom = false,
bool displayZoomControls = false,
bool withLocalStorage = true,
bool withLocalUrl = false,
String? localUrlScope,
bool withOverviewMode = false,
bool scrollBar = true,
bool supportMultipleWindows = false,
bool appCacheEnabled = false,
bool allowFileURLs = false,
bool useWideViewPort = false,
String? invalidUrlRegex,
bool geolocationEnabled = false,
bool debuggingEnabled = false,
bool ignoreSSLErrors = false,
}) async {
final args = <String, dynamic>{
'url': url,
'withJavascript': withJavascript,
'clearCache': clearCache,
'hidden': hidden,
'clearCookies': clearCookies,
'mediaPlaybackRequiresUserGesture': mediaPlaybackRequiresUserGesture,
'enableAppScheme': enableAppScheme,
'userAgent': userAgent,
'withZoom': withZoom,
'displayZoomControls': displayZoomControls,
'withLocalStorage': withLocalStorage,
'withLocalUrl': withLocalUrl,
'localUrlScope': localUrlScope,
'scrollBar': scrollBar,
'supportMultipleWindows': supportMultipleWindows,
'appCacheEnabled': appCacheEnabled,
'allowFileURLs': allowFileURLs,
'useWideViewPort': useWideViewPort,
'invalidUrlRegex': invalidUrlRegex,
'geolocationEnabled': geolocationEnabled,
'withOverviewMode': withOverviewMode,
'debuggingEnabled': debuggingEnabled,
'ignoreSSLErrors': ignoreSSLErrors,
};
if (headers != null) {
args['headers'] = headers;
}
_assertJavascriptChannelNamesAreUnique(javascriptChannels);
javascriptChannels.forEach((channel) {
_javascriptChannels[channel.name] = channel;
});
args['javascriptChannelNames'] =
_extractJavascriptChannelNames(javascriptChannels).toList();
if (rect != null) {
args['rect'] = {
'left': rect.left,
'top': rect.top,
'width': rect.width,
'height': rect.height,
};
}
await _channel.invokeMethod('launch', args);
}