launch method

Future<Null> launch(
  1. String url, {
  2. Map<String, String>? headers,
  3. Set<JavascriptChannel>? javascriptChannels,
  4. bool? withJavascript,
  5. bool? clearCache,
  6. bool? clearCookies,
  7. bool? mediaPlaybackRequiresUserGesture,
  8. bool? hidden,
  9. bool? enableAppScheme,
  10. Rect? rect,
  11. String? userAgent,
  12. bool? withZoom,
  13. bool? displayZoomControls,
  14. bool? withLocalStorage,
  15. bool? withLocalUrl,
  16. String? localUrlScope,
  17. bool? withOverviewMode,
  18. bool? scrollBar,
  19. bool? supportMultipleWindows,
  20. bool? appCacheEnabled,
  21. bool? allowFileURLs,
  22. bool? useWideViewPort,
  23. String? invalidUrlRegex,
  24. bool? geolocationEnabled,
  25. bool? debuggingEnabled,
  26. bool? ignoreSSLErrors,
})

Start the Webview with url

  • headers specify additional HTTP headers
  • withJavascript enable Javascript or not for the Webview
  • clearCache clear the cache of the Webview
  • clearCookies clear all cookies of the Webview
  • hidden not show
  • rect: show in rect, fullscreen if null
  • enableAppScheme: false will enable all schemes, true only for httt/https/about android: Not implemented yet
  • userAgent: set the User-Agent of WebView
  • withZoom: enable zoom on webview
  • withLocalStorage enable 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.0
  • localUrlScope: 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 scrollbar
  • supportMultipleWindows enable multiple windows support in Android
  • invalidUrlRegex is 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 webview
  • withOverviewMode: 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<Null> launch(
    String url, {
      Map<String, String>? headers,
      Set<JavascriptChannel>? javascriptChannels,
      bool? withJavascript,
      bool? clearCache,
      bool? clearCookies,
      bool? mediaPlaybackRequiresUserGesture,
      bool? hidden,
      bool? enableAppScheme,
      Rect? rect,
      String? userAgent,
      bool? withZoom,
      bool? displayZoomControls,
      bool? withLocalStorage,
      bool? withLocalUrl,
      String? localUrlScope,
      bool? withOverviewMode,
      bool? scrollBar,
      bool? supportMultipleWindows,
      bool? appCacheEnabled,
      bool? allowFileURLs,
      bool? useWideViewPort,
      String? invalidUrlRegex,
      bool? geolocationEnabled,
      bool? debuggingEnabled,
      bool? ignoreSSLErrors,
    }) async {
  final args = <String, dynamic>{
    'url': url,
    'withJavascript': withJavascript ?? true,
    'clearCache': clearCache ?? false,
    'hidden': hidden ?? false,
    'clearCookies': clearCookies ?? false,
    'mediaPlaybackRequiresUserGesture': mediaPlaybackRequiresUserGesture ?? true,
    'enableAppScheme': enableAppScheme ?? true,
    'userAgent': userAgent,
    'withZoom': withZoom ?? false,
    'displayZoomControls': displayZoomControls ?? false,
    'withLocalStorage': withLocalStorage ?? true,
    'withLocalUrl': withLocalUrl ?? false,
    'localUrlScope': localUrlScope,
    'scrollBar': scrollBar ?? true,
    'supportMultipleWindows': supportMultipleWindows ?? false,
    'appCacheEnabled': appCacheEnabled ?? false,
    'allowFileURLs': allowFileURLs ?? false,
    'useWideViewPort': useWideViewPort ?? false,
    'invalidUrlRegex': invalidUrlRegex,
    'geolocationEnabled': geolocationEnabled ?? false,
    'withOverviewMode': withOverviewMode ?? false,
    'debuggingEnabled': debuggingEnabled ?? false,
    'ignoreSSLErrors': ignoreSSLErrors ?? false,
  };

  if (headers != null) {
    args['headers'] = headers;
  }
  _assertJavascriptChannelNamesAreUnique(javascriptChannels);

  if (javascriptChannels != null) {
    javascriptChannels.forEach((channel) {
      _javascriptChannels[channel.name] = channel;
    });
  } else {
    if (_javascriptChannels.isNotEmpty) {
      _javascriptChannels.clear();
    }
  }

  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);
}