InAppWebViewSettings constructor

InAppWebViewSettings({
  1. bool? useShouldOverrideUrlLoading,
  2. bool? useOnLoadResource,
  3. bool? useOnDownloadStart,
  4. @Deprecated("Use InAppWebViewController.clearAllCache instead") bool? clearCache = false,
  5. String? userAgent = "",
  6. String? applicationNameForUserAgent = "",
  7. bool? javaScriptEnabled = true,
  8. bool? javaScriptCanOpenWindowsAutomatically = false,
  9. bool? mediaPlaybackRequiresUserGesture = true,
  10. int? minimumFontSize,
  11. bool? verticalScrollBarEnabled = true,
  12. bool? horizontalScrollBarEnabled = true,
  13. List<String>? resourceCustomSchemes = const [],
  14. List<ContentBlocker>? contentBlockers = const [],
  15. UserPreferredContentMode? preferredContentMode = UserPreferredContentMode.RECOMMENDED,
  16. bool? useShouldInterceptAjaxRequest,
  17. bool? useOnAjaxReadyStateChange,
  18. bool? useOnAjaxProgress,
  19. bool? interceptOnlyAsyncAjaxRequests = true,
  20. bool? useShouldInterceptFetchRequest,
  21. bool? incognito = false,
  22. bool? cacheEnabled = true,
  23. bool? transparentBackground = false,
  24. bool? disableVerticalScroll = false,
  25. bool? disableHorizontalScroll = false,
  26. bool? disableContextMenu = false,
  27. bool? supportZoom = true,
  28. bool? allowFileAccessFromFileURLs = false,
  29. bool? allowUniversalAccessFromFileURLs = false,
  30. int? textZoom,
  31. @Deprecated("Use CookieManager.removeSessionCookies instead") bool? clearSessionCache = false,
  32. bool? builtInZoomControls = true,
  33. bool? displayZoomControls = false,
  34. bool? databaseEnabled = true,
  35. bool? domStorageEnabled = true,
  36. bool? useWideViewPort = true,
  37. bool? safeBrowsingEnabled = true,
  38. MixedContentMode? mixedContentMode,
  39. bool? allowContentAccess = true,
  40. bool? allowFileAccess = true,
  41. String? appCachePath,
  42. bool? blockNetworkImage = false,
  43. bool? blockNetworkLoads = false,
  44. CacheMode? cacheMode = CacheMode.LOAD_DEFAULT,
  45. String? cursiveFontFamily = "cursive",
  46. int? defaultFixedFontSize = 16,
  47. int? defaultFontSize = 16,
  48. String? defaultTextEncodingName = "UTF-8",
  49. ActionModeMenuItem? disabledActionModeMenuItems,
  50. String? fantasyFontFamily = "fantasy",
  51. String? fixedFontFamily = "monospace",
  52. @Deprecated("Use algorithmicDarkeningAllowed instead") ForceDark? forceDark,
  53. @Deprecated("Use algorithmicDarkeningAllowed instead") ForceDarkStrategy? forceDarkStrategy,
  54. bool? geolocationEnabled = true,
  55. LayoutAlgorithm? layoutAlgorithm,
  56. bool? loadWithOverviewMode = true,
  57. bool? loadsImagesAutomatically = true,
  58. int? minimumLogicalFontSize = 8,
  59. bool? needInitialFocus = true,
  60. bool? offscreenPreRaster = false,
  61. String? sansSerifFontFamily = "sans-serif",
  62. String? serifFontFamily = "sans-serif",
  63. String? standardFontFamily = "sans-serif",
  64. @Deprecated('') bool? saveFormData = true,
  65. bool? thirdPartyCookiesEnabled = true,
  66. bool? hardwareAcceleration = true,
  67. int? initialScale = 0,
  68. bool? supportMultipleWindows = false,
  69. String? regexToCancelSubFramesLoading,
  70. String? regexToAllowSyncUrlLoading,
  71. bool? useHybridComposition = true,
  72. bool? useShouldInterceptRequest,
  73. bool? useOnRenderProcessGone,
  74. OverScrollMode? overScrollMode = OverScrollMode.IF_CONTENT_SCROLLS,
  75. bool? networkAvailable,
  76. ScrollBarStyle? scrollBarStyle = ScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY,
  77. VerticalScrollbarPosition? verticalScrollbarPosition = VerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT,
  78. int? scrollBarDefaultDelayBeforeFade,
  79. bool? scrollbarFadingEnabled = true,
  80. int? scrollBarFadeDuration,
  81. RendererPriorityPolicy? rendererPriorityPolicy,
  82. bool? disableDefaultErrorPage = false,
  83. Color? verticalScrollbarThumbColor,
  84. Color? verticalScrollbarTrackColor,
  85. Color? horizontalScrollbarThumbColor,
  86. Color? horizontalScrollbarTrackColor,
  87. bool? algorithmicDarkeningAllowed = false,
  88. bool? enterpriseAuthenticationAppLinkPolicyEnabled = true,
  89. WebAuthenticationSupport? webAuthenticationSupport,
  90. String? containerId,
  91. ProxySettings? proxySettings,
  92. bool? paymentRequestEnabled,
  93. Uint8List? defaultVideoPoster,
  94. Set<String>? requestedWithHeaderOriginAllowList,
  95. bool? disallowOverScroll = false,
  96. bool? enableViewportScale = false,
  97. bool? suppressesIncrementalRendering = false,
  98. bool? allowsAirPlayForMediaPlayback = true,
  99. bool? allowsBackForwardNavigationGestures = true,
  100. bool? allowsLinkPreview = true,
  101. bool? ignoresViewportScaleLimits = false,
  102. bool? allowsInlineMediaPlayback = false,
  103. bool? allowsPictureInPictureMediaPlayback = true,
  104. bool? isFraudulentWebsiteWarningEnabled = true,
  105. SelectionGranularity? selectionGranularity = SelectionGranularity.DYNAMIC,
  106. List<DataDetectorTypes>? dataDetectorTypes = const [DataDetectorTypes.NONE],
  107. bool? sharedCookiesEnabled = false,
  108. bool? automaticallyAdjustsScrollIndicatorInsets = false,
  109. bool? accessibilityIgnoresInvertColors = false,
  110. ScrollViewDecelerationRate? decelerationRate = ScrollViewDecelerationRate.NORMAL,
  111. bool? alwaysBounceVertical = false,
  112. bool? alwaysBounceHorizontal = false,
  113. bool? scrollsToTop = true,
  114. bool? isPagingEnabled = false,
  115. double? maximumZoomScale = 1.0,
  116. double? minimumZoomScale = 1.0,
  117. ScrollViewContentInsetAdjustmentBehavior? contentInsetAdjustmentBehavior = ScrollViewContentInsetAdjustmentBehavior.NEVER,
  118. bool? isDirectionalLockEnabled = false,
  119. String? mediaType,
  120. double? pageZoom = 1.0,
  121. bool? limitsNavigationsToAppBoundDomains = false,
  122. bool? useOnNavigationResponse,
  123. bool? applePayAPIEnabled = false,
  124. WebUri? allowingReadAccessTo,
  125. bool? disableLongPressContextMenuOnLinks = false,
  126. bool? disableInputAccessoryView = false,
  127. bool? disableAutocorrection = false,
  128. Color? underPageBackgroundColor,
  129. bool? isTextInteractionEnabled = true,
  130. IOSWritingToolsBehavior? writingToolsBehavior,
  131. bool? isSiteSpecificQuirksModeEnabled = true,
  132. bool? upgradeKnownHostsToHTTPS = true,
  133. bool? isElementFullscreenEnabled = true,
  134. bool? useNativeFullscreenContainer = true,
  135. bool? isFindInteractionEnabled = false,
  136. EdgeInsets? minimumViewportInset,
  137. EdgeInsets? maximumViewportInset,
  138. bool? isInspectable = false,
  139. bool? shouldPrintBackgrounds = false,
  140. bool? allowBackgroundAudioPlaying = false,
  141. WebViewAssetLoader? webViewAssetLoader,
  142. Set<String>? javaScriptHandlersOriginAllowList,
  143. bool? javaScriptHandlersForMainFrameOnly,
  144. bool? javaScriptBridgeEnabled = true,
  145. Set<String>? javaScriptBridgeOriginAllowList,
  146. bool? javaScriptBridgeForMainFrameOnly,
  147. Set<String>? pluginScriptsOriginAllowList,
  148. bool? pluginScriptsForMainFrameOnly = false,
  149. int? scrollMultiplier = 1,
  150. bool? statusBarEnabled = true,
  151. bool? browserAcceleratorKeysEnabled = true,
  152. bool? generalAutofillEnabled = true,
  153. bool? passwordAutosaveEnabled = false,
  154. bool? pinchZoomEnabled = true,
  155. PdfToolbarItems? hiddenPdfToolbarItems = PdfToolbarItems.NONE,
  156. bool? reputationCheckingRequired = true,
  157. bool? nonClientRegionSupportEnabled = false,
  158. bool? isUserInteractionEnabled = true,
  159. bool? handleAcceleratorKeyPressed = false,
  160. double? alpha,
  161. bool? useOnShowFileChooser,
  162. String? iframeAllow,
  163. bool? iframeAllowFullscreen,
  164. Set<Sandbox>? iframeSandbox,
  165. ReferrerPolicy? iframeReferrerPolicy,
  166. String? iframeName,
  167. String? iframeCsp,
  168. String? iframeRole,
  169. String? iframeAriaHidden,
  170. bool? enableWriteConsoleMessagesToStdout = false,
  171. bool? enableSmoothScrolling = true,
  172. bool? enableCaretBrowsing = false,
  173. bool? enablePageCache = true,
  174. bool? drawCompositingIndicators = false,
  175. bool? enableResizableTextAreas = true,
  176. bool? enableTabsToLinks = true,
  177. bool? enableSpatialNavigation = false,
  178. String? pictographFontFamily,
  179. List<String>? corsAllowlist,
  180. bool? itpEnabled = false,
  181. bool? darkMode,
  182. bool? disableAnimations,
  183. bool? fontAntialias,
  184. FontHintingStyle? fontHintingStyle,
  185. FontSubpixelLayout? fontSubpixelLayout,
  186. double? fontDPI,
  187. int? cursorBlinkTime,
  188. int? doubleClickDistance,
  189. int? doubleClickTime,
  190. int? dragThreshold,
  191. int? keyRepeatDelay,
  192. int? keyRepeatInterval,
  193. bool? javaScriptCanAccessClipboard = false,
  194. bool? allowModalDialogs = false,
  195. bool? disableWebSecurity = false,
  196. bool? enableWebRTC = true,
  197. String? webRTCUdpPortsRange,
  198. bool? enableMedia = true,
  199. bool? enableEncryptedMedia = true,
  200. bool? enableMediaCapabilities = true,
  201. bool? enableMockCaptureDevices = false,
  202. String? mediaContentTypesRequiringHardwareSupport,
  203. bool? enableJavaScriptMarkup = true,
  204. bool? enable2DCanvasAcceleration = false,
  205. bool? allowTopNavigationToDataUrls = false,
})

Officially Supported Platforms/Implementations:

  • Android WebView
  • iOS WKWebView
  • macOS WKWebView
  • Web <iframe>
  • Windows WebView2

Implementation

InAppWebViewSettings({
  this.useShouldOverrideUrlLoading,
  this.useOnLoadResource,
  this.useOnDownloadStart,
  @Deprecated("Use InAppWebViewController.clearAllCache instead")
  this.clearCache = false,
  this.userAgent = "",
  this.applicationNameForUserAgent = "",
  this.javaScriptEnabled = true,
  this.javaScriptCanOpenWindowsAutomatically = false,
  this.mediaPlaybackRequiresUserGesture = true,
  this.minimumFontSize,
  this.verticalScrollBarEnabled = true,
  this.horizontalScrollBarEnabled = true,
  this.resourceCustomSchemes = const [],
  this.contentBlockers = const [],
  this.preferredContentMode = UserPreferredContentMode.RECOMMENDED,
  this.useShouldInterceptAjaxRequest,
  this.useOnAjaxReadyStateChange,
  this.useOnAjaxProgress,
  this.interceptOnlyAsyncAjaxRequests = true,
  this.useShouldInterceptFetchRequest,
  this.incognito = false,
  this.cacheEnabled = true,
  this.transparentBackground = false,
  this.disableVerticalScroll = false,
  this.disableHorizontalScroll = false,
  this.disableContextMenu = false,
  this.supportZoom = true,
  this.allowFileAccessFromFileURLs = false,
  this.allowUniversalAccessFromFileURLs = false,
  this.textZoom,
  @Deprecated("Use CookieManager.removeSessionCookies instead")
  this.clearSessionCache = false,
  this.builtInZoomControls = true,
  this.displayZoomControls = false,
  this.databaseEnabled = true,
  this.domStorageEnabled = true,
  this.useWideViewPort = true,
  this.safeBrowsingEnabled = true,
  this.mixedContentMode,
  this.allowContentAccess = true,
  this.allowFileAccess = true,
  this.appCachePath,
  this.blockNetworkImage = false,
  this.blockNetworkLoads = false,
  this.cacheMode = CacheMode.LOAD_DEFAULT,
  this.cursiveFontFamily = "cursive",
  this.defaultFixedFontSize = 16,
  this.defaultFontSize = 16,
  this.defaultTextEncodingName = "UTF-8",
  this.disabledActionModeMenuItems,
  this.fantasyFontFamily = "fantasy",
  this.fixedFontFamily = "monospace",
  @Deprecated("Use algorithmicDarkeningAllowed instead") this.forceDark,
  @Deprecated("Use algorithmicDarkeningAllowed instead")
  this.forceDarkStrategy,
  this.geolocationEnabled = true,
  this.layoutAlgorithm,
  this.loadWithOverviewMode = true,
  this.loadsImagesAutomatically = true,
  this.minimumLogicalFontSize = 8,
  this.needInitialFocus = true,
  this.offscreenPreRaster = false,
  this.sansSerifFontFamily = "sans-serif",
  this.serifFontFamily = "sans-serif",
  this.standardFontFamily = "sans-serif",
  @Deprecated('') this.saveFormData = true,
  this.thirdPartyCookiesEnabled = true,
  this.hardwareAcceleration = true,
  this.initialScale = 0,
  this.supportMultipleWindows = false,
  this.regexToCancelSubFramesLoading,
  this.regexToAllowSyncUrlLoading,
  this.useHybridComposition = true,
  this.useShouldInterceptRequest,
  this.useOnRenderProcessGone,
  this.overScrollMode = OverScrollMode.IF_CONTENT_SCROLLS,
  this.networkAvailable,
  this.scrollBarStyle = ScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY,
  this.verticalScrollbarPosition =
      VerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT,
  this.scrollBarDefaultDelayBeforeFade,
  this.scrollbarFadingEnabled = true,
  this.scrollBarFadeDuration,
  this.rendererPriorityPolicy,
  this.disableDefaultErrorPage = false,
  this.verticalScrollbarThumbColor,
  this.verticalScrollbarTrackColor,
  this.horizontalScrollbarThumbColor,
  this.horizontalScrollbarTrackColor,
  this.algorithmicDarkeningAllowed = false,
  this.enterpriseAuthenticationAppLinkPolicyEnabled = true,
  this.webAuthenticationSupport,
  this.containerId,
  this.proxySettings,
  this.paymentRequestEnabled,
  this.defaultVideoPoster,
  this.requestedWithHeaderOriginAllowList,
  this.disallowOverScroll = false,
  this.enableViewportScale = false,
  this.suppressesIncrementalRendering = false,
  this.allowsAirPlayForMediaPlayback = true,
  this.allowsBackForwardNavigationGestures = true,
  this.allowsLinkPreview = true,
  this.ignoresViewportScaleLimits = false,
  this.allowsInlineMediaPlayback = false,
  this.allowsPictureInPictureMediaPlayback = true,
  this.isFraudulentWebsiteWarningEnabled = true,
  this.selectionGranularity = SelectionGranularity.DYNAMIC,
  this.dataDetectorTypes = const [DataDetectorTypes.NONE],
  this.sharedCookiesEnabled = false,
  this.automaticallyAdjustsScrollIndicatorInsets = false,
  this.accessibilityIgnoresInvertColors = false,
  this.decelerationRate = ScrollViewDecelerationRate.NORMAL,
  this.alwaysBounceVertical = false,
  this.alwaysBounceHorizontal = false,
  this.scrollsToTop = true,
  this.isPagingEnabled = false,
  this.maximumZoomScale = 1.0,
  this.minimumZoomScale = 1.0,
  this.contentInsetAdjustmentBehavior =
      ScrollViewContentInsetAdjustmentBehavior.NEVER,
  this.isDirectionalLockEnabled = false,
  this.mediaType,
  this.pageZoom = 1.0,
  this.limitsNavigationsToAppBoundDomains = false,
  this.useOnNavigationResponse,
  this.applePayAPIEnabled = false,
  this.allowingReadAccessTo,
  this.disableLongPressContextMenuOnLinks = false,
  this.disableInputAccessoryView = false,
  this.disableAutocorrection = false,
  this.underPageBackgroundColor,
  this.isTextInteractionEnabled = true,
  this.writingToolsBehavior,
  this.isSiteSpecificQuirksModeEnabled = true,
  this.upgradeKnownHostsToHTTPS = true,
  this.isElementFullscreenEnabled = true,
  this.useNativeFullscreenContainer = true,
  this.isFindInteractionEnabled = false,
  this.minimumViewportInset,
  this.maximumViewportInset,
  this.isInspectable = false,
  this.shouldPrintBackgrounds = false,
  this.allowBackgroundAudioPlaying = false,
  this.webViewAssetLoader,
  this.javaScriptHandlersOriginAllowList,
  this.javaScriptHandlersForMainFrameOnly,
  this.javaScriptBridgeEnabled = true,
  this.javaScriptBridgeOriginAllowList,
  this.javaScriptBridgeForMainFrameOnly,
  this.pluginScriptsOriginAllowList,
  this.pluginScriptsForMainFrameOnly = false,
  this.scrollMultiplier = 1,
  this.statusBarEnabled = true,
  this.browserAcceleratorKeysEnabled = true,
  this.generalAutofillEnabled = true,
  this.passwordAutosaveEnabled = false,
  this.pinchZoomEnabled = true,
  this.hiddenPdfToolbarItems = PdfToolbarItems.NONE,
  this.reputationCheckingRequired = true,
  this.nonClientRegionSupportEnabled = false,
  this.isUserInteractionEnabled = true,
  this.handleAcceleratorKeyPressed = false,
  this.alpha,
  this.useOnShowFileChooser,
  this.iframeAllow,
  this.iframeAllowFullscreen,
  this.iframeSandbox,
  this.iframeReferrerPolicy,
  this.iframeName,
  this.iframeCsp,
  this.iframeRole,
  this.iframeAriaHidden,
  this.enableWriteConsoleMessagesToStdout = false,
  this.enableSmoothScrolling = true,
  this.enableCaretBrowsing = false,
  this.enablePageCache = true,
  this.drawCompositingIndicators = false,
  this.enableResizableTextAreas = true,
  this.enableTabsToLinks = true,
  this.enableSpatialNavigation = false,
  this.pictographFontFamily,
  this.corsAllowlist,
  this.itpEnabled = false,
  this.darkMode,
  this.disableAnimations,
  this.fontAntialias,
  this.fontHintingStyle,
  this.fontSubpixelLayout,
  this.fontDPI,
  this.cursorBlinkTime,
  this.doubleClickDistance,
  this.doubleClickTime,
  this.dragThreshold,
  this.keyRepeatDelay,
  this.keyRepeatInterval,
  this.javaScriptCanAccessClipboard = false,
  this.allowModalDialogs = false,
  this.disableWebSecurity = false,
  this.enableWebRTC = true,
  this.webRTCUdpPortsRange,
  this.enableMedia = true,
  this.enableEncryptedMedia = true,
  this.enableMediaCapabilities = true,
  this.enableMockCaptureDevices = false,
  this.mediaContentTypesRequiringHardwareSupport,
  this.enableJavaScriptMarkup = true,
  this.enable2DCanvasAcceleration = false,
  this.allowTopNavigationToDataUrls = false,
}) {
  if (this.minimumFontSize == null)
    this.minimumFontSize = Util.isAndroid ? 8 : 0;
  assert(
    this.resourceCustomSchemes == null ||
        (this.resourceCustomSchemes != null &&
            !this.resourceCustomSchemes!.contains("http") &&
            !this.resourceCustomSchemes!.contains("https")),
  );
  assert(
    allowingReadAccessTo == null || allowingReadAccessTo!.isScheme("file"),
  );
  assert(
    (minimumViewportInset == null && maximumViewportInset == null) ||
        minimumViewportInset != null &&
            maximumViewportInset != null &&
            minimumViewportInset!.isNonNegative &&
            maximumViewportInset!.isNonNegative &&
            minimumViewportInset!.vertical <=
                maximumViewportInset!.vertical &&
            minimumViewportInset!.horizontal <=
                maximumViewportInset!.horizontal,
    "minimumViewportInset cannot be larger than maximumViewportInset",
  );
}