2020-09-07 08:32:24 +00:00
import ' package:flutter/foundation.dart ' ;
2019-10-28 03:58:25 +00:00
2019-11-29 15:59:18 +00:00
import ' content_blocker.dart ' ;
2019-10-31 02:20:07 +00:00
import ' types.dart ' ;
2020-05-28 23:03:45 +00:00
import ' webview.dart ' ;
2019-10-26 20:11:23 +00:00
2019-10-31 02:20:07 +00:00
class AndroidOptions { }
2019-12-01 11:55:06 +00:00
2019-11-04 00:39:23 +00:00
class IosOptions { }
2019-10-31 02:20:07 +00:00
2019-10-26 20:11:23 +00:00
class WebViewOptions {
Map < String , dynamic > toMap ( ) {
return { } ;
}
2019-11-04 00:39:23 +00:00
static WebViewOptions fromMap ( Map < String , dynamic > map ) {
2021-01-28 16:10:15 +00:00
return new WebViewOptions ( ) ;
2019-11-04 00:39:23 +00:00
}
2020-05-29 17:56:03 +00:00
2020-06-13 01:50:19 +00:00
WebViewOptions copy ( ) {
return WebViewOptions . fromMap ( this . toMap ( ) ) ;
}
2020-05-29 17:56:03 +00:00
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2019-10-26 20:11:23 +00:00
}
2019-10-27 03:35:05 +00:00
class BrowserOptions {
Map < String , dynamic > toMap ( ) {
return { } ;
}
2019-11-04 00:39:23 +00:00
static BrowserOptions fromMap ( Map < String , dynamic > map ) {
2021-01-28 16:10:15 +00:00
return new BrowserOptions ( ) ;
2019-11-04 00:39:23 +00:00
}
2020-05-29 17:56:03 +00:00
2020-06-13 01:50:19 +00:00
BrowserOptions copy ( ) {
return BrowserOptions . fromMap ( this . toMap ( ) ) ;
}
2020-05-29 17:56:03 +00:00
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2019-11-04 00:39:23 +00:00
}
class ChromeSafariBrowserOptions {
Map < String , dynamic > toMap ( ) {
return { } ;
}
static ChromeSafariBrowserOptions fromMap ( Map < String , dynamic > map ) {
2021-01-28 16:10:15 +00:00
return new ChromeSafariBrowserOptions ( ) ;
2019-11-04 00:39:23 +00:00
}
2020-05-29 17:56:03 +00:00
2020-06-13 01:50:19 +00:00
ChromeSafariBrowserOptions copy ( ) {
return ChromeSafariBrowserOptions . fromMap ( this . toMap ( ) ) ;
}
2020-05-29 17:56:03 +00:00
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2019-10-27 03:35:05 +00:00
}
2019-11-08 18:12:21 +00:00
///This class represents all the cross-platform WebView options available.
2019-12-01 11:55:06 +00:00
class InAppWebViewOptions
implements WebViewOptions , BrowserOptions , AndroidOptions , IosOptions {
2021-02-09 23:15:10 +00:00
///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool useShouldOverrideUrlLoading ;
2019-12-01 11:55:06 +00:00
2021-02-09 23:15:10 +00:00
///Set to `true` to be able to listen at the [WebView.onLoadResource] event. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool useOnLoadResource ;
2019-12-01 11:55:06 +00:00
2021-02-09 23:15:10 +00:00
///Set to `true` to be able to listen at the [WebView.onDownloadStart] event. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool useOnDownloadStart ;
2019-12-01 11:55:06 +00:00
2020-06-20 19:58:29 +00:00
///Set to `true` to have all the browser's cache cleared before the new WebView is opened. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool clearCache ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the user-agent for the WebView.
///
///**NOTE**: available on iOS 9.0+.
2019-10-26 20:11:23 +00:00
String userAgent ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Append to the existing user-agent. Setting userAgent will override this.
///
///**NOTE**: available on Android 17+ and on iOS 9.0+.
2019-11-07 23:32:29 +00:00
String applicationNameForUserAgent ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` to enable JavaScript. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool javaScriptEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool javaScriptCanOpenWindowsAutomatically ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`.
2019-11-08 21:31:57 +00:00
///
///**NOTE**: available on iOS 10.0+.
2019-10-26 20:11:23 +00:00
bool mediaPlaybackRequiresUserGesture ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the minimum font size. The default value is `8` for Android, `0` for iOS.
2021-01-28 16:10:15 +00:00
int ? minimumFontSize ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Define whether the vertical scrollbar should be drawn or not. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool verticalScrollBarEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Define whether the horizontal scrollbar should be drawn or not. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool horizontalScrollBarEnabled ;
2019-12-01 11:55:06 +00:00
2021-02-09 23:15:10 +00:00
///List of custom schemes that the WebView must handle. Use the [WebView.onLoadResourceCustomScheme] event to intercept resource requests with custom scheme.
2019-11-08 21:31:57 +00:00
///
///**NOTE**: available on iOS 11.0+.
2019-10-26 20:11:23 +00:00
List < String > resourceCustomSchemes ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///List of [ContentBlocker] that are a set of rules used to block content in the browser window.
2019-11-08 21:31:57 +00:00
///
///**NOTE**: available on iOS 11.0+.
2019-10-26 20:11:23 +00:00
List < ContentBlocker > contentBlockers ;
2019-12-01 11:55:06 +00:00
2019-12-18 00:56:21 +00:00
///Sets the content mode that the WebView needs to use when loading and rendering a webpage. The default value is [UserPreferredContentMode.RECOMMENDED].
2019-11-08 18:12:21 +00:00
///
///**NOTE**: available on iOS 13.0+.
2021-01-28 16:10:15 +00:00
UserPreferredContentMode ? preferredContentMode ;
2019-12-01 11:55:06 +00:00
2021-02-09 23:15:10 +00:00
///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. The default value is `false`.
2019-11-05 02:44:22 +00:00
bool useShouldInterceptAjaxRequest ;
2019-12-01 11:55:06 +00:00
2021-02-09 23:15:10 +00:00
///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. The default value is `false`.
2019-11-05 02:44:22 +00:00
bool useShouldInterceptFetchRequest ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` to open a browser window with incognito mode. The default value is `false`.
///
///**NOTE**: available on iOS 9.0+.
2021-01-28 16:10:15 +00:00
///On Android, by setting this option to `true`, it will clear all the cookies of all WebView instances,
///because there isn't any way to make the website data store non-persistent for the specific WebView instance such as on iOS.
2019-11-07 23:32:29 +00:00
bool incognito ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether WebView should use browser caching. The default value is `true`.
///
///**NOTE**: available on iOS 9.0+.
2019-11-07 23:32:29 +00:00
bool cacheEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
2019-11-07 23:32:29 +00:00
bool transparentBackground ;
2019-12-01 11:55:06 +00:00
2019-11-18 21:21:35 +00:00
///Set to `true` to disable vertical scroll. The default value is `false`.
bool disableVerticalScroll ;
2019-12-01 11:55:06 +00:00
2019-11-18 21:21:35 +00:00
///Set to `true` to disable horizontal scroll. The default value is `false`.
bool disableHorizontalScroll ;
2019-10-26 20:11:23 +00:00
2020-05-21 01:34:39 +00:00
///Set to `true` to disable context menu. The default value is `false`.
bool disableContextMenu ;
2020-06-12 02:04:41 +00:00
///Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
bool supportZoom ;
2021-01-28 17:56:04 +00:00
///Sets whether cross-origin requests in the context of a file scheme URL should be allowed to access content from other file scheme URLs.
///Note that some accesses such as image HTML elements don't follow same-origin rules and aren't affected by this setting.
///
///Don't enable this setting if you open files that may be created or altered by external sources.
///Enabling this setting allows malicious scripts loaded in a `file://` context to access arbitrary local files including WebView cookies and app private data.
///
///Note that the value of this setting is ignored if the value of [allowUniversalAccessFromFileURLs] is `true`.
///
///The default value is `false`.
bool allowFileAccessFromFileURLs ;
///Sets whether cross-origin requests in the context of a file scheme URL should be allowed to access content from any origin.
///This includes access to content from other file scheme URLs or web contexts.
///Note that some access such as image HTML elements doesn't follow same-origin rules and isn't affected by this setting.
///
///Don't enable this setting if you open files that may be created or altered by external sources.
///Enabling this setting allows malicious scripts loaded in a `file://` context to launch cross-site scripting attacks,
///either accessing arbitrary local files including WebView cookies, app private data or even credentials used on arbitrary web sites.
///
///The default value is `false`.
bool allowUniversalAccessFromFileURLs ;
2019-12-01 11:55:06 +00:00
InAppWebViewOptions (
{ this . useShouldOverrideUrlLoading = false ,
this . useOnLoadResource = false ,
this . useOnDownloadStart = false ,
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 [ ] ,
2020-05-29 17:56:03 +00:00
this . preferredContentMode = UserPreferredContentMode . RECOMMENDED ,
2019-12-01 11:55:06 +00:00
this . useShouldInterceptAjaxRequest = false ,
this . useShouldInterceptFetchRequest = false ,
this . incognito = false ,
this . cacheEnabled = true ,
this . transparentBackground = false ,
this . disableVerticalScroll = false ,
2020-05-21 01:34:39 +00:00
this . disableHorizontalScroll = false ,
2020-06-12 02:04:41 +00:00
this . disableContextMenu = false ,
2021-01-28 17:56:04 +00:00
this . supportZoom = true ,
this . allowFileAccessFromFileURLs = false ,
this . allowUniversalAccessFromFileURLs = false } ) {
2019-12-01 11:55:06 +00:00
if ( this . minimumFontSize = = null )
2020-09-07 08:32:24 +00:00
this . minimumFontSize = defaultTargetPlatform = = TargetPlatform . android ? 8 : 0 ;
2019-12-01 11:55:06 +00:00
assert ( ! this . resourceCustomSchemes . contains ( " http " ) & &
! this . resourceCustomSchemes . contains ( " https " ) ) ;
}
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
List < Map < String , Map < String , dynamic > > > contentBlockersMapList = [ ] ;
contentBlockers . forEach ( ( contentBlocker ) {
contentBlockersMapList . add ( contentBlocker . toMap ( ) ) ;
} ) ;
return {
" useShouldOverrideUrlLoading " : useShouldOverrideUrlLoading ,
" useOnLoadResource " : useOnLoadResource ,
" useOnDownloadStart " : useOnDownloadStart ,
" clearCache " : clearCache ,
" userAgent " : userAgent ,
2019-11-07 23:32:29 +00:00
" applicationNameForUserAgent " : applicationNameForUserAgent ,
2019-10-26 20:11:23 +00:00
" javaScriptEnabled " : javaScriptEnabled ,
2019-12-01 11:55:06 +00:00
" javaScriptCanOpenWindowsAutomatically " :
javaScriptCanOpenWindowsAutomatically ,
2019-10-26 20:11:23 +00:00
" mediaPlaybackRequiresUserGesture " : mediaPlaybackRequiresUserGesture ,
" verticalScrollBarEnabled " : verticalScrollBarEnabled ,
" horizontalScrollBarEnabled " : horizontalScrollBarEnabled ,
" resourceCustomSchemes " : resourceCustomSchemes ,
" contentBlockers " : contentBlockersMapList ,
2019-11-05 02:44:22 +00:00
" preferredContentMode " : preferredContentMode ? . toValue ( ) ,
" useShouldInterceptAjaxRequest " : useShouldInterceptAjaxRequest ,
2019-11-07 23:32:29 +00:00
" useShouldInterceptFetchRequest " : useShouldInterceptFetchRequest ,
" incognito " : incognito ,
" cacheEnabled " : cacheEnabled ,
2019-11-18 21:21:35 +00:00
" transparentBackground " : transparentBackground ,
" disableVerticalScroll " : disableVerticalScroll ,
2020-05-21 01:34:39 +00:00
" disableHorizontalScroll " : disableHorizontalScroll ,
2020-06-12 02:04:41 +00:00
" disableContextMenu " : disableContextMenu ,
2021-01-28 17:56:04 +00:00
" supportZoom " : supportZoom ,
" allowFileAccessFromFileURLs " : allowFileAccessFromFileURLs ,
" allowUniversalAccessFromFileURLs " : allowUniversalAccessFromFileURLs
2019-10-26 20:11:23 +00:00
} ;
}
2019-11-04 00:39:23 +00:00
static InAppWebViewOptions fromMap ( Map < String , dynamic > map ) {
List < ContentBlocker > contentBlockers = [ ] ;
2021-01-28 16:10:15 +00:00
List < dynamic > ? contentBlockersMapList = map [ " contentBlockers " ] ;
2019-11-04 00:39:23 +00:00
if ( contentBlockersMapList ! = null ) {
contentBlockersMapList . forEach ( ( contentBlocker ) {
contentBlockers . add ( ContentBlocker . fromMap (
2019-12-01 11:55:06 +00:00
Map < dynamic , Map < dynamic , dynamic > > . from (
Map < dynamic , dynamic > . from ( contentBlocker ) ) ) ) ;
2019-11-04 00:39:23 +00:00
} ) ;
}
2020-05-28 23:03:45 +00:00
InAppWebViewOptions options = InAppWebViewOptions ( ) ;
2019-11-04 00:39:23 +00:00
options . useShouldOverrideUrlLoading = map [ " useShouldOverrideUrlLoading " ] ;
options . useOnLoadResource = map [ " useOnLoadResource " ] ;
options . useOnDownloadStart = map [ " useOnDownloadStart " ] ;
options . clearCache = map [ " clearCache " ] ;
options . userAgent = map [ " userAgent " ] ;
2019-11-07 23:32:29 +00:00
options . applicationNameForUserAgent = map [ " applicationNameForUserAgent " ] ;
2019-11-04 00:39:23 +00:00
options . javaScriptEnabled = map [ " javaScriptEnabled " ] ;
2019-12-01 11:55:06 +00:00
options . javaScriptCanOpenWindowsAutomatically =
map [ " javaScriptCanOpenWindowsAutomatically " ] ;
options . mediaPlaybackRequiresUserGesture =
map [ " mediaPlaybackRequiresUserGesture " ] ;
2019-11-04 00:39:23 +00:00
options . verticalScrollBarEnabled = map [ " verticalScrollBarEnabled " ] ;
options . horizontalScrollBarEnabled = map [ " horizontalScrollBarEnabled " ] ;
2019-12-01 11:55:06 +00:00
options . resourceCustomSchemes =
List < String > . from ( map [ " resourceCustomSchemes " ] ? ? [ ] ) ;
2019-11-04 00:39:23 +00:00
options . contentBlockers = contentBlockers ;
2019-12-01 11:55:06 +00:00
options . preferredContentMode =
2020-05-29 17:56:03 +00:00
UserPreferredContentMode . fromValue ( map [ " preferredContentMode " ] ) ;
2019-12-01 11:55:06 +00:00
options . useShouldInterceptAjaxRequest =
map [ " useShouldInterceptAjaxRequest " ] ;
options . useShouldInterceptFetchRequest =
map [ " useShouldInterceptFetchRequest " ] ;
2019-11-07 23:32:29 +00:00
options . incognito = map [ " incognito " ] ;
options . cacheEnabled = map [ " cacheEnabled " ] ;
options . transparentBackground = map [ " transparentBackground " ] ;
2019-11-18 21:21:35 +00:00
options . disableVerticalScroll = map [ " disableVerticalScroll " ] ;
options . disableHorizontalScroll = map [ " disableHorizontalScroll " ] ;
2020-05-21 01:34:39 +00:00
options . disableContextMenu = map [ " disableContextMenu " ] ;
2020-06-12 02:04:41 +00:00
options . supportZoom = map [ " supportZoom " ] ;
2021-01-28 17:56:04 +00:00
options . allowFileAccessFromFileURLs = map [ " allowFileAccessFromFileURLs " ] ;
options . allowUniversalAccessFromFileURLs = map [ " allowUniversalAccessFromFileURLs " ] ;
2019-11-04 00:39:23 +00:00
return options ;
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
InAppWebViewOptions copy ( ) {
return InAppWebViewOptions . fromMap ( this . toMap ( ) ) ;
}
2019-10-26 20:11:23 +00:00
}
2019-11-08 21:31:57 +00:00
///This class represents all the Android-only WebView options available.
2019-12-01 11:55:06 +00:00
class AndroidInAppWebViewOptions
implements WebViewOptions , BrowserOptions , AndroidOptions {
2019-11-25 22:04:17 +00:00
///Sets the text zoom of the page in percent. The default value is `100`.
2019-11-08 18:12:21 +00:00
int textZoom ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` to have the session cookie cache cleared before the new window is opened.
2019-10-26 20:11:23 +00:00
bool clearSessionCache ;
2019-12-01 11:55:06 +00:00
2020-06-12 02:04:41 +00:00
///Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool builtInZoomControls ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool displayZoomControls ;
2019-12-01 11:55:06 +00:00
2019-12-16 22:58:10 +00:00
///Set to `true` if you want the database storage API is enabled. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool databaseEnabled ;
2019-12-01 11:55:06 +00:00
2019-12-09 23:29:09 +00:00
///Set to `true` if you want the DOM storage API is enabled. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool domStorageEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport.
///When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels.
///When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used.
///If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool useWideViewPort ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links.
///Safe Browsing is enabled by default for devices which support it.
///
///**NOTE**: available on Android 26+.
2019-10-26 20:11:23 +00:00
bool safeBrowsingEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin.
///
///**NOTE**: available on Android 21+.
2021-01-28 16:10:15 +00:00
AndroidMixedContentMode ? mixedContentMode ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default value is `true`.
2019-10-28 03:58:25 +00:00
bool allowContentAccess ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Enables or disables file access within WebView. Note that this enables or disables file system access only.
2021-01-28 17:56:04 +00:00
///Assets and resources are still accessible using `file:///android_asset` and `file:///android_res`. The default value is `true`.
2019-10-28 03:58:25 +00:00
bool allowFileAccess ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the path to the Application Caches files. In order for the Application Caches API to be enabled, this option must be set a path to which the application can write.
///This option is used one time: repeated calls are ignored.
2021-01-28 16:10:15 +00:00
String ? appCachePath ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether the WebView should not load image resources from the network (resources accessed via http and https URI schemes). The default value is `false`.
2019-10-28 03:58:25 +00:00
bool blockNetworkImage ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether the WebView should not load resources from the network. The default value is `false`.
2019-10-28 03:58:25 +00:00
bool blockNetworkLoads ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed.
2019-12-18 00:56:21 +00:00
///When navigating back, content is not revalidated, instead the content is just retrieved from the cache. The default value is [AndroidCacheMode.LOAD_DEFAULT].
2021-01-28 16:10:15 +00:00
AndroidCacheMode ? cacheMode ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the cursive font family name. The default value is `"cursive"`.
2019-10-28 03:58:25 +00:00
String cursiveFontFamily ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the default fixed font size. The default value is `16`.
2019-10-28 03:58:25 +00:00
int defaultFixedFontSize ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the default font size. The default value is `16`.
2019-10-28 03:58:25 +00:00
int defaultFontSize ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the default text encoding name to use when decoding html pages. The default value is `"UTF-8"`.
2019-10-28 03:58:25 +00:00
String defaultTextEncodingName ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Disables the action mode menu items according to menuItems flag.
///
///**NOTE**: available on Android 24+.
2021-01-28 16:10:15 +00:00
AndroidActionModeMenuItem ? disabledActionModeMenuItems ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the fantasy font family name. The default value is `"fantasy"`.
2019-10-28 03:58:25 +00:00
String fantasyFontFamily ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the fixed font family name. The default value is `"monospace"`.
2019-10-28 03:58:25 +00:00
String fixedFontFamily ;
2019-12-01 11:55:06 +00:00
2019-12-18 00:56:21 +00:00
///Set the force dark mode for this WebView. The default value is [AndroidForceDark.FORCE_DARK_OFF].
2019-11-08 18:12:21 +00:00
///
///**NOTE**: available on Android 29+.
2021-01-28 16:10:15 +00:00
AndroidForceDark ? forceDark ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether Geolocation API is enabled. The default value is `true`.
2019-10-28 03:58:25 +00:00
bool geolocationEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the underlying layout algorithm. This will cause a re-layout of the WebView.
2021-01-28 16:10:15 +00:00
AndroidLayoutAlgorithm ? layoutAlgorithm ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width.
///This setting is taken into account when the content width is greater than the width of the WebView control, for example, when [useWideViewPort] is enabled.
///The default value is `false`.
2019-10-28 03:58:25 +00:00
bool loadWithOverviewMode ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether the WebView should load image resources. Note that this method controls loading of all images, including those embedded using the data URI scheme.
///Note that if the value of this setting is changed from false to true, all images resources referenced by content currently displayed by the WebView are loaded automatically.
///The default value is `true`.
2019-10-28 03:58:25 +00:00
bool loadsImagesAutomatically ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the minimum logical font size. The default is `8`.
2019-10-28 03:58:25 +00:00
int minimumLogicalFontSize ;
2019-12-01 11:55:06 +00:00
2019-11-25 22:04:17 +00:00
///Sets the initial scale for this WebView. 0 means default. The behavior for the default scale depends on the state of [useWideViewPort] and [loadWithOverviewMode].
2019-11-08 18:12:21 +00:00
///If the content fits into the WebView control by width, then the zoom is set to 100%. For wide content, the behavior depends on the state of [loadWithOverviewMode].
///If its value is true, the content will be zoomed out to be fit by width into the WebView control, otherwise not.
///If initial scale is greater than 0, WebView starts with this value as initial scale.
///Please note that unlike the scale properties in the viewport meta tag, this method doesn't take the screen density into account.
///The default is `0`.
2019-11-08 06:39:15 +00:00
int initialScale ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Tells the WebView whether it needs to set a node. The default value is `true`.
2019-10-28 03:58:25 +00:00
bool needInitialFocus ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether this WebView should raster tiles when it is offscreen but attached to a window.
///Turning this on can avoid rendering artifacts when animating an offscreen WebView on-screen.
///Offscreen WebViews in this mode use more memory. The default value is `false`.
///
///**NOTE**: available on Android 23+.
2019-10-28 03:58:25 +00:00
bool offscreenPreRaster ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the sans-serif font family name. The default value is `"sans-serif"`.
2019-10-28 03:58:25 +00:00
String sansSerifFontFamily ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the serif font family name. The default value is `"sans-serif"`.
2019-10-28 03:58:25 +00:00
String serifFontFamily ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets the standard font family name. The default value is `"sans-serif"`.
2019-10-28 03:58:25 +00:00
String standardFontFamily ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Sets whether the WebView should save form data. In Android O, the platform has implemented a fully functional Autofill feature to store form data.
///Therefore, the Webview form data save feature is disabled. Note that the feature will continue to be supported on older versions of Android as before.
2019-12-09 23:29:09 +00:00
///The default value is `true`.
2019-11-07 23:32:29 +00:00
bool saveFormData ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Boolean value to enable third party cookies in the WebView.
///Used on Android Lollipop and above only as third party cookies are enabled by default on Android Kitkat and below and on iOS.
///The default value is `true`.
///
///**NOTE**: available on Android 21+.
2019-11-07 23:32:29 +00:00
bool thirdPartyCookiesEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 18:12:21 +00:00
///Boolean value to enable Hardware Acceleration in the WebView.
///The default value is `true`.
2019-11-07 23:32:29 +00:00
bool hardwareAcceleration ;
2019-10-26 20:11:23 +00:00
2020-06-30 08:58:59 +00:00
///Sets whether the WebView supports multiple windows.
2021-02-09 23:15:10 +00:00
///If set to `true`, [WebView.onCreateWindow] event must be implemented by the host application. The default value is `false`.
2019-12-09 23:29:09 +00:00
bool supportMultipleWindows ;
2021-02-09 23:15:10 +00:00
///Regular expression used by [WebView.shouldOverrideUrlLoading] event to cancel navigation requests for frames that are not the main frame.
2019-12-11 00:41:38 +00:00
///If the url request of a subframe matches the regular expression, then the request of that subframe is canceled.
2021-01-28 16:10:15 +00:00
String ? regexToCancelSubFramesLoading ;
2019-12-09 23:29:09 +00:00
2020-08-24 15:48:50 +00:00
///Set to `true` to enable Flutter's new Hybrid Composition. The default value is `false`.
2020-08-27 14:41:40 +00:00
///Hybrid Composition is supported starting with Flutter v1.20+.
///
///**NOTE**: It is recommended to use Hybrid Composition only on Android 10+ for a release app,
///as it can cause framerate drops on animations in Android 9 and lower (see [Hybrid-Composition#performance](https://github.com/flutter/flutter/wiki/Hybrid-Composition#performance)).
2020-08-24 15:48:50 +00:00
bool useHybridComposition ;
2020-05-28 23:03:45 +00:00
///Set to `true` to be able to listen at the [WebView.androidShouldInterceptRequest] event. The default value is `false`.
bool useShouldInterceptRequest ;
///Set to `true` to be able to listen at the [WebView.androidOnRenderProcessGone] event. The default value is `false`.
bool useOnRenderProcessGone ;
///Sets the WebView's over-scroll mode.
///Setting the over-scroll mode of a WebView will have an effect only if the WebView is capable of scrolling.
///The default value is [AndroidOverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS].
2021-01-28 16:10:15 +00:00
AndroidOverScrollMode ? overScrollMode ;
2020-05-28 23:03:45 +00:00
///Informs WebView of the network state.
///This is used to set the JavaScript property `window.navigator.isOnline` and generates the online/offline event as specified in HTML5, sec. 5.7.7.
2021-01-28 16:10:15 +00:00
bool ? networkAvailable ;
2020-05-28 23:03:45 +00:00
2020-06-30 08:58:59 +00:00
///Specifies the style of the scrollbars. The scrollbars can be overlaid or inset.
2020-05-28 23:03:45 +00:00
///When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view.
///For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable,
///you can use SCROLLBARS_INSIDE_OVERLAY or SCROLLBARS_INSIDE_INSET. If you want them to appear at the edge of the view, ignoring the padding,
///then you can use SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.
///The default value is [AndroidScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY].
2021-01-28 16:10:15 +00:00
AndroidScrollBarStyle ? scrollBarStyle ;
2020-05-28 23:03:45 +00:00
2020-06-30 08:58:59 +00:00
///Sets the position of the vertical scroll bar.
2020-05-28 23:03:45 +00:00
///The default value is [AndroidVerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT].
2021-01-28 16:10:15 +00:00
AndroidVerticalScrollbarPosition ? verticalScrollbarPosition ;
2020-05-28 23:03:45 +00:00
///Defines the delay in milliseconds that a scrollbar waits before fade out.
2021-01-28 16:10:15 +00:00
int ? scrollBarDefaultDelayBeforeFade ;
2020-05-28 23:03:45 +00:00
2020-06-30 08:58:59 +00:00
///Defines whether scrollbars will fade when the view is not scrolling.
2020-05-28 23:03:45 +00:00
///The default value is `true`.
bool scrollbarFadingEnabled ;
2020-06-30 08:58:59 +00:00
///Defines the scrollbar fade duration in milliseconds.
2021-01-28 16:10:15 +00:00
int ? scrollBarFadeDuration ;
2020-05-28 23:03:45 +00:00
2020-06-30 08:58:59 +00:00
///Sets the renderer priority policy for this WebView.
2021-01-28 16:10:15 +00:00
RendererPriorityPolicy ? rendererPriorityPolicy ;
2020-05-28 23:03:45 +00:00
2020-06-30 08:58:59 +00:00
///Sets whether the default Android error page should be disabled.
///The default value is `false`.
2021-01-28 16:10:15 +00:00
bool ? disableDefaultErrorPage ;
2020-06-30 08:58:59 +00:00
2020-05-28 23:03:45 +00:00
AndroidInAppWebViewOptions ( {
this . textZoom = 100 ,
this . clearSessionCache = false ,
2020-06-12 02:04:41 +00:00
this . builtInZoomControls = true ,
2020-05-28 23:03:45 +00:00
this . displayZoomControls = false ,
2020-06-12 02:04:41 +00:00
this . databaseEnabled = true ,
2020-05-28 23:03:45 +00:00
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 = AndroidCacheMode . LOAD_DEFAULT ,
this . cursiveFontFamily = " cursive " ,
this . defaultFixedFontSize = 16 ,
this . defaultFontSize = 16 ,
this . defaultTextEncodingName = " UTF-8 " ,
this . disabledActionModeMenuItems ,
this . fantasyFontFamily = " fantasy " ,
this . fixedFontFamily = " monospace " ,
this . forceDark = AndroidForceDark . FORCE_DARK_OFF ,
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 " ,
this . saveFormData = true ,
this . thirdPartyCookiesEnabled = true ,
this . hardwareAcceleration = true ,
this . initialScale = 0 ,
this . supportMultipleWindows = false ,
this . regexToCancelSubFramesLoading ,
2020-08-24 15:48:50 +00:00
this . useHybridComposition = false ,
2020-05-28 23:03:45 +00:00
this . useShouldInterceptRequest = false ,
this . useOnRenderProcessGone = false ,
this . overScrollMode = AndroidOverScrollMode . OVER_SCROLL_IF_CONTENT_SCROLLS ,
this . networkAvailable ,
this . scrollBarStyle = AndroidScrollBarStyle . SCROLLBARS_INSIDE_OVERLAY ,
2020-05-29 17:56:03 +00:00
this . verticalScrollbarPosition =
AndroidVerticalScrollbarPosition . SCROLLBAR_POSITION_DEFAULT ,
2020-05-28 23:03:45 +00:00
this . scrollBarDefaultDelayBeforeFade ,
this . scrollbarFadingEnabled = true ,
this . scrollBarFadeDuration ,
this . rendererPriorityPolicy ,
2020-06-30 08:58:59 +00:00
this . disableDefaultErrorPage ,
2020-05-28 23:03:45 +00:00
} ) ;
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
return {
2019-11-08 18:12:21 +00:00
" textZoom " : textZoom ,
2019-10-26 20:11:23 +00:00
" clearSessionCache " : clearSessionCache ,
" builtInZoomControls " : builtInZoomControls ,
" displayZoomControls " : displayZoomControls ,
" databaseEnabled " : databaseEnabled ,
" domStorageEnabled " : domStorageEnabled ,
" useWideViewPort " : useWideViewPort ,
" safeBrowsingEnabled " : safeBrowsingEnabled ,
2019-10-28 03:58:25 +00:00
" mixedContentMode " : mixedContentMode ? . toValue ( ) ,
" allowContentAccess " : allowContentAccess ,
" allowFileAccess " : allowFileAccess ,
" appCachePath " : appCachePath ,
" blockNetworkImage " : blockNetworkImage ,
" blockNetworkLoads " : blockNetworkLoads ,
" cacheMode " : cacheMode ? . toValue ( ) ,
" cursiveFontFamily " : cursiveFontFamily ,
" defaultFixedFontSize " : defaultFixedFontSize ,
" defaultFontSize " : defaultFontSize ,
" defaultTextEncodingName " : defaultTextEncodingName ,
" disabledActionModeMenuItems " : disabledActionModeMenuItems ? . toValue ( ) ,
" fantasyFontFamily " : fantasyFontFamily ,
" fixedFontFamily " : fixedFontFamily ,
" forceDark " : forceDark ? . toValue ( ) ,
" geolocationEnabled " : geolocationEnabled ,
" layoutAlgorithm " : layoutAlgorithm ? . toValue ( ) ,
" loadWithOverviewMode " : loadWithOverviewMode ,
" loadsImagesAutomatically " : loadsImagesAutomatically ,
" minimumLogicalFontSize " : minimumLogicalFontSize ,
2019-11-08 06:39:15 +00:00
" initialScale " : initialScale ,
2019-10-28 03:58:25 +00:00
" needInitialFocus " : needInitialFocus ,
" offscreenPreRaster " : offscreenPreRaster ,
" sansSerifFontFamily " : sansSerifFontFamily ,
" serifFontFamily " : serifFontFamily ,
2019-11-07 23:32:29 +00:00
" standardFontFamily " : standardFontFamily ,
" saveFormData " : saveFormData ,
" thirdPartyCookiesEnabled " : thirdPartyCookiesEnabled ,
2019-12-09 23:29:09 +00:00
" hardwareAcceleration " : hardwareAcceleration ,
" supportMultipleWindows " : supportMultipleWindows ,
2020-08-24 15:48:50 +00:00
" useHybridComposition " : useHybridComposition ,
2020-05-28 23:03:45 +00:00
" regexToCancelSubFramesLoading " : regexToCancelSubFramesLoading ,
" useShouldInterceptRequest " : useShouldInterceptRequest ,
" useOnRenderProcessGone " : useOnRenderProcessGone ,
" overScrollMode " : overScrollMode ? . toValue ( ) ,
" networkAvailable " : networkAvailable ,
" scrollBarStyle " : scrollBarStyle ? . toValue ( ) ,
" verticalScrollbarPosition " : verticalScrollbarPosition ? . toValue ( ) ,
" scrollBarDefaultDelayBeforeFade " : scrollBarDefaultDelayBeforeFade ,
" scrollbarFadingEnabled " : scrollbarFadingEnabled ,
" scrollBarFadeDuration " : scrollBarFadeDuration ,
2020-06-30 08:58:59 +00:00
" rendererPriorityPolicy " : rendererPriorityPolicy ? . toMap ( ) ,
" disableDefaultErrorPage " : disableDefaultErrorPage
2019-10-26 20:11:23 +00:00
} ;
}
2019-11-04 00:39:23 +00:00
static AndroidInAppWebViewOptions fromMap ( Map < String , dynamic > map ) {
2020-05-28 23:03:45 +00:00
AndroidInAppWebViewOptions options = AndroidInAppWebViewOptions ( ) ;
2019-11-08 18:12:21 +00:00
options . textZoom = map [ " textZoom " ] ;
2019-11-04 00:39:23 +00:00
options . clearSessionCache = map [ " clearSessionCache " ] ;
options . builtInZoomControls = map [ " builtInZoomControls " ] ;
options . displayZoomControls = map [ " displayZoomControls " ] ;
options . databaseEnabled = map [ " databaseEnabled " ] ;
options . domStorageEnabled = map [ " domStorageEnabled " ] ;
options . useWideViewPort = map [ " useWideViewPort " ] ;
options . safeBrowsingEnabled = map [ " safeBrowsingEnabled " ] ;
2019-12-01 11:55:06 +00:00
options . mixedContentMode =
2019-12-18 00:56:21 +00:00
AndroidMixedContentMode . fromValue ( map [ " mixedContentMode " ] ) ;
2019-11-04 00:39:23 +00:00
options . allowContentAccess = map [ " allowContentAccess " ] ;
options . allowFileAccess = map [ " allowFileAccess " ] ;
options . appCachePath = map [ " appCachePath " ] ;
options . blockNetworkImage = map [ " blockNetworkImage " ] ;
options . blockNetworkLoads = map [ " blockNetworkLoads " ] ;
2020-05-29 17:56:03 +00:00
options . cacheMode = AndroidCacheMode . fromValue ( map [ " cacheMode " ] ) ;
2019-11-04 00:39:23 +00:00
options . cursiveFontFamily = map [ " cursiveFontFamily " ] ;
options . defaultFixedFontSize = map [ " defaultFixedFontSize " ] ;
options . defaultFontSize = map [ " defaultFontSize " ] ;
options . defaultTextEncodingName = map [ " defaultTextEncodingName " ] ;
2019-12-01 11:55:06 +00:00
options . disabledActionModeMenuItems =
2020-05-29 17:56:03 +00:00
AndroidActionModeMenuItem . fromValue ( map [ " disabledActionModeMenuItems " ] ) ;
2019-11-04 00:39:23 +00:00
options . fantasyFontFamily = map [ " fantasyFontFamily " ] ;
options . fixedFontFamily = map [ " fixedFontFamily " ] ;
2020-05-29 17:56:03 +00:00
options . forceDark = AndroidForceDark . fromValue ( map [ " forceDark " ] ) ;
2019-11-04 00:39:23 +00:00
options . geolocationEnabled = map [ " geolocationEnabled " ] ;
2019-12-01 11:55:06 +00:00
options . layoutAlgorithm =
2019-12-18 00:56:21 +00:00
AndroidLayoutAlgorithm . fromValue ( map [ " layoutAlgorithm " ] ) ;
2019-11-04 00:39:23 +00:00
options . loadWithOverviewMode = map [ " loadWithOverviewMode " ] ;
options . loadsImagesAutomatically = map [ " loadsImagesAutomatically " ] ;
options . minimumLogicalFontSize = map [ " minimumLogicalFontSize " ] ;
2019-11-08 06:39:15 +00:00
options . initialScale = map [ " initialScale " ] ;
2019-11-04 00:39:23 +00:00
options . needInitialFocus = map [ " needInitialFocus " ] ;
options . offscreenPreRaster = map [ " offscreenPreRaster " ] ;
options . sansSerifFontFamily = map [ " sansSerifFontFamily " ] ;
options . serifFontFamily = map [ " serifFontFamily " ] ;
options . standardFontFamily = map [ " standardFontFamily " ] ;
2019-11-07 23:32:29 +00:00
options . saveFormData = map [ " saveFormData " ] ;
options . thirdPartyCookiesEnabled = map [ " thirdPartyCookiesEnabled " ] ;
options . hardwareAcceleration = map [ " hardwareAcceleration " ] ;
2019-12-09 23:29:09 +00:00
options . supportMultipleWindows = map [ " supportMultipleWindows " ] ;
2020-05-29 17:56:03 +00:00
options . regexToCancelSubFramesLoading =
map [ " regexToCancelSubFramesLoading " ] ;
2020-08-24 15:48:50 +00:00
options . useHybridComposition = map [ " useHybridComposition " ] ;
2020-05-28 23:03:45 +00:00
options . useShouldInterceptRequest = map [ " useShouldInterceptRequest " ] ;
options . useOnRenderProcessGone = map [ " useOnRenderProcessGone " ] ;
2020-05-29 17:56:03 +00:00
options . overScrollMode =
AndroidOverScrollMode . fromValue ( map [ " overScrollMode " ] ) ;
2020-05-28 23:03:45 +00:00
options . networkAvailable = map [ " networkAvailable " ] ;
2020-05-29 17:56:03 +00:00
options . scrollBarStyle =
AndroidScrollBarStyle . fromValue ( map [ " scrollBarStyle " ] ) ;
options . verticalScrollbarPosition =
AndroidVerticalScrollbarPosition . fromValue (
map [ " verticalScrollbarPosition " ] ) ;
options . scrollBarDefaultDelayBeforeFade =
map [ " scrollBarDefaultDelayBeforeFade " ] ;
2020-05-28 23:03:45 +00:00
options . scrollbarFadingEnabled = map [ " scrollbarFadingEnabled " ] ;
options . scrollBarFadeDuration = map [ " scrollBarFadeDuration " ] ;
2020-05-29 17:56:03 +00:00
options . rendererPriorityPolicy = RendererPriorityPolicy . fromMap (
map [ " rendererPriorityPolicy " ] ? . cast < String , dynamic > ( ) ) ;
2020-06-30 08:58:59 +00:00
options . disableDefaultErrorPage = map [ " disableDefaultErrorPage " ] ;
2019-11-04 00:39:23 +00:00
return options ;
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
AndroidInAppWebViewOptions copy ( ) {
return AndroidInAppWebViewOptions . fromMap ( this . toMap ( ) ) ;
}
2019-10-26 20:11:23 +00:00
}
2019-11-08 21:31:57 +00:00
///This class represents all the iOS-only WebView options available.
2019-12-16 22:58:10 +00:00
class IOSInAppWebViewOptions
2019-12-01 11:55:06 +00:00
implements WebViewOptions , BrowserOptions , IosOptions {
2019-11-08 21:31:57 +00:00
///Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool disallowOverScroll ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool enableViewportScale ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool suppressesIncrementalRendering ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to allow AirPlay. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool allowsAirPlayForMediaPlayback ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool allowsBackForwardNavigationGestures ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`.
///
///**NOTE**: available on iOS 9.0+.
2019-10-26 20:11:23 +00:00
bool allowsLinkPreview ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent.
///The ignoresViewportScaleLimits property overrides the `user-scalable` HTML property in a webpage. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool ignoresViewportScaleLimits ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls.
///For this to work, add the `webkit-playsinline` attribute to any `<video>` elements. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool allowsInlineMediaPlayback ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
///
///**NOTE**: available on iOS 9.0+.
2019-10-26 20:11:23 +00:00
bool allowsPictureInPictureMediaPlayback ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///A Boolean value indicating whether warnings should be shown for suspected fraudulent content such as phishing or malware.
///According to the official documentation, this feature is currently available in the following region: China.
///The default value is `true`.
///
///**NOTE**: available on iOS 13.0+.
2019-10-28 03:58:25 +00:00
bool isFraudulentWebsiteWarningEnabled ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///The level of granularity with which the user can interactively select content in the web view.
2019-12-18 00:56:21 +00:00
///The default value is [IOSWKSelectionGranularity.DYNAMIC]
IOSWKSelectionGranularity selectionGranularity ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Specifying a dataDetectoryTypes value adds interactivity to web content that matches the value.
2019-12-18 00:56:21 +00:00
///For example, Safari adds a link to “apple.com” in the text “Visit apple.com” if the dataDetectorTypes property is set to [IOSWKDataDetectorTypes.LINK].
///The default value is [IOSWKDataDetectorTypes.NONE].
2019-11-08 21:31:57 +00:00
///
///**NOTE**: available on iOS 10.0+.
2019-12-18 00:56:21 +00:00
List < IOSWKDataDetectorTypes > dataDetectorTypes ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set `true` if shared cookies from `HTTPCookieStorage.shared` should used for every load request in the WebView.
///The default value is `false`.
///
///**NOTE**: available on iOS 11.0+.
2019-11-07 23:32:29 +00:00
bool sharedCookiesEnabled ;
2019-10-28 03:58:25 +00:00
2019-12-16 22:58:10 +00:00
///Configures whether the scroll indicator insets are automatically adjusted by the system.
///The default value is `false`.
///
///**NOTE**: available on iOS 13.0+.
bool automaticallyAdjustsScrollIndicatorInsets ;
2020-06-19 19:59:43 +00:00
///A Boolean value indicating whether the WebView ignores an accessibility request to invert its colors.
2020-05-09 02:36:07 +00:00
///The default value is `false`.
///
///**NOTE**: available on iOS 11.0+.
bool accessibilityIgnoresInvertColors ;
///A [IOSUIScrollViewDecelerationRate] value that determines the rate of deceleration after the user lifts their finger.
///The default value is [IOSUIScrollViewDecelerationRate.NORMAL].
IOSUIScrollViewDecelerationRate decelerationRate ;
///A Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content.
///The default value is `false`.
bool alwaysBounceVertical ;
///A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.
///The default value is `false`.
bool alwaysBounceHorizontal ;
///A Boolean value that controls whether the scroll-to-top gesture is enabled.
///The scroll-to-top gesture is a tap on the status bar. When a user makes this gesture,
///the system asks the scroll view closest to the status bar to scroll to the top.
///The default value is `true`.
bool scrollsToTop ;
///A Boolean value that determines whether paging is enabled for the scroll view.
///If the value of this property is true, the scroll view stops on multiples of the scroll view’ s bounds when the user scrolls.
///The default value is `false`.
bool isPagingEnabled ;
///A floating-point value that specifies the maximum scale factor that can be applied to the scroll view's content.
///This value determines how large the content can be scaled.
///It must be greater than the minimum zoom scale for zooming to be enabled.
///The default value is `1.0`.
double maximumZoomScale ;
///A floating-point value that specifies the minimum scale factor that can be applied to the scroll view's content.
///This value determines how small the content can be scaled.
///The default value is `1.0`.
double minimumZoomScale ;
2020-06-13 01:50:19 +00:00
///Configures how safe area insets are added to the adjusted content inset.
///The default value is [IOSUIScrollViewContentInsetAdjustmentBehavior.NEVER].
IOSUIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior ;
2021-02-03 14:17:15 +00:00
///A Boolean value that determines whether scrolling is disabled in a particular direction.
///If this property is `false`, scrolling is permitted in both horizontal and vertical directions.
///If this property is `true` and the user begins dragging in one general direction (horizontally or vertically),
///the scroll view disables scrolling in the other direction.
///If the drag direction is diagonal, then scrolling will not be locked and the user can drag in any direction until the drag completes.
///The default value is `false`.
bool isDirectionalLockEnabled ;
2021-02-04 00:43:55 +00:00
///The media type for the contents of the web view.
///When the value of this property is `null`, the web view derives the current media type from the CSS media property of its content.
///If you assign a value other than `null` to this property, the web view uses the value you provide instead.
///The default value of this property is `null`.
///
///**NOTE**: available on iOS 14.0+.
String ? mediaType ;
///The scale factor by which the web view scales content relative to its bounds.
///The default value of this property is `1.0`, which displays the content without any scaling.
///Changing the value of this property is equivalent to setting the CSS `zoom` property on all page content.
///
///**NOTE**: available on iOS 14.0+.
double pageZoom ;
///A Boolean value that indicates whether the web view limits navigation to pages within the app’ s domain.
///Check [App-Bound Domains](https://webkit.org/blog/10882/app-bound-domains/) for more details.
///The default value is `false`.
///
///**NOTE**: available on iOS 14.0+.
bool limitsNavigationsToAppBoundDomains ;
2021-02-09 23:15:10 +00:00
///Set to `true` to be able to listen at the [WebView.iosOnNavigationResponse] event. The default value is `false`.
bool useOnNavigationResponse ;
2019-12-16 22:58:10 +00:00
IOSInAppWebViewOptions (
2019-12-01 11:55:06 +00:00
{ 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 ,
2019-12-18 00:56:21 +00:00
this . selectionGranularity = IOSWKSelectionGranularity . DYNAMIC ,
this . dataDetectorTypes = const [ IOSWKDataDetectorTypes . NONE ] ,
2019-12-16 22:58:10 +00:00
this . sharedCookiesEnabled = false ,
2020-05-09 02:36:07 +00:00
this . automaticallyAdjustsScrollIndicatorInsets = false ,
this . accessibilityIgnoresInvertColors = false ,
this . decelerationRate = IOSUIScrollViewDecelerationRate . NORMAL ,
this . alwaysBounceVertical = false ,
this . alwaysBounceHorizontal = false ,
this . scrollsToTop = true ,
this . isPagingEnabled = false ,
this . maximumZoomScale = 1.0 ,
2020-06-13 01:50:19 +00:00
this . minimumZoomScale = 1.0 ,
2020-06-21 22:09:35 +00:00
this . contentInsetAdjustmentBehavior =
2021-02-03 14:17:15 +00:00
IOSUIScrollViewContentInsetAdjustmentBehavior . NEVER ,
2021-02-04 00:43:55 +00:00
this . isDirectionalLockEnabled = false ,
this . mediaType ,
this . pageZoom = 1.0 ,
2021-02-09 23:15:10 +00:00
this . limitsNavigationsToAppBoundDomains = false ,
this . useOnNavigationResponse = false } ) ;
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
2019-10-28 03:58:25 +00:00
List < String > dataDetectorTypesList = [ ] ;
dataDetectorTypes . forEach ( ( dataDetectorType ) {
dataDetectorTypesList . add ( dataDetectorType . toValue ( ) ) ;
} ) ;
2019-10-26 20:11:23 +00:00
return {
" disallowOverScroll " : disallowOverScroll ,
" enableViewportScale " : enableViewportScale ,
" suppressesIncrementalRendering " : suppressesIncrementalRendering ,
" allowsAirPlayForMediaPlayback " : allowsAirPlayForMediaPlayback ,
2019-12-01 11:55:06 +00:00
" allowsBackForwardNavigationGestures " :
allowsBackForwardNavigationGestures ,
2019-10-26 20:11:23 +00:00
" allowsLinkPreview " : allowsLinkPreview ,
" ignoresViewportScaleLimits " : ignoresViewportScaleLimits ,
" allowsInlineMediaPlayback " : allowsInlineMediaPlayback ,
2019-12-01 11:55:06 +00:00
" allowsPictureInPictureMediaPlayback " :
allowsPictureInPictureMediaPlayback ,
2019-10-28 03:58:25 +00:00
" isFraudulentWebsiteWarningEnabled " : isFraudulentWebsiteWarningEnabled ,
" selectionGranularity " : selectionGranularity . toValue ( ) ,
2019-11-07 23:32:29 +00:00
" dataDetectorTypes " : dataDetectorTypesList ,
2019-12-16 22:58:10 +00:00
" sharedCookiesEnabled " : sharedCookiesEnabled ,
2020-05-29 17:56:03 +00:00
" automaticallyAdjustsScrollIndicatorInsets " :
automaticallyAdjustsScrollIndicatorInsets ,
2020-05-09 02:36:07 +00:00
" accessibilityIgnoresInvertColors " : accessibilityIgnoresInvertColors ,
" decelerationRate " : decelerationRate . toValue ( ) ,
" alwaysBounceVertical " : alwaysBounceVertical ,
" alwaysBounceHorizontal " : alwaysBounceHorizontal ,
" scrollsToTop " : scrollsToTop ,
" isPagingEnabled " : isPagingEnabled ,
" maximumZoomScale " : maximumZoomScale ,
2020-06-13 01:50:19 +00:00
" minimumZoomScale " : minimumZoomScale ,
2021-02-03 14:17:15 +00:00
" contentInsetAdjustmentBehavior " : contentInsetAdjustmentBehavior . toValue ( ) ,
" isDirectionalLockEnabled " : isDirectionalLockEnabled ,
2021-02-04 00:43:55 +00:00
" mediaType " : mediaType ,
" pageZoom " : pageZoom ,
" limitsNavigationsToAppBoundDomains " : limitsNavigationsToAppBoundDomains ,
2021-02-09 23:15:10 +00:00
" useOnNavigationResponse " : useOnNavigationResponse ,
2019-10-26 20:11:23 +00:00
} ;
}
2019-11-04 00:39:23 +00:00
2019-12-16 22:58:10 +00:00
static IOSInAppWebViewOptions fromMap ( Map < String , dynamic > map ) {
2019-12-18 00:56:21 +00:00
List < IOSWKDataDetectorTypes > dataDetectorTypes = [ ] ;
2019-12-01 11:55:06 +00:00
List < String > dataDetectorTypesList =
List < String > . from ( map [ " dataDetectorTypes " ] ? ? [ ] ) ;
2021-01-28 16:10:15 +00:00
dataDetectorTypesList . forEach ( ( dataDetectorTypeValue ) {
var dataDetectorType = IOSWKDataDetectorTypes . fromValue ( dataDetectorTypeValue ) ;
if ( dataDetectorType ! = null ) {
dataDetectorTypes . add ( dataDetectorType ) ;
}
2019-11-04 00:39:23 +00:00
} ) ;
2020-05-28 23:03:45 +00:00
IOSInAppWebViewOptions options = IOSInAppWebViewOptions ( ) ;
2019-11-04 00:39:23 +00:00
options . disallowOverScroll = map [ " disallowOverScroll " ] ;
options . enableViewportScale = map [ " enableViewportScale " ] ;
2019-12-01 11:55:06 +00:00
options . suppressesIncrementalRendering =
map [ " suppressesIncrementalRendering " ] ;
options . allowsAirPlayForMediaPlayback =
map [ " allowsAirPlayForMediaPlayback " ] ;
options . allowsBackForwardNavigationGestures =
map [ " allowsBackForwardNavigationGestures " ] ;
2019-11-04 00:39:23 +00:00
options . allowsLinkPreview = map [ " allowsLinkPreview " ] ;
options . ignoresViewportScaleLimits = map [ " ignoresViewportScaleLimits " ] ;
options . allowsInlineMediaPlayback = map [ " allowsInlineMediaPlayback " ] ;
2019-12-01 11:55:06 +00:00
options . allowsPictureInPictureMediaPlayback =
map [ " allowsPictureInPictureMediaPlayback " ] ;
options . isFraudulentWebsiteWarningEnabled =
map [ " isFraudulentWebsiteWarningEnabled " ] ;
options . selectionGranularity =
2021-01-28 16:10:15 +00:00
IOSWKSelectionGranularity . fromValue ( map [ " selectionGranularity " ] ) ! ;
2019-11-04 00:39:23 +00:00
options . dataDetectorTypes = dataDetectorTypes ;
2019-11-07 23:32:29 +00:00
options . sharedCookiesEnabled = map [ " sharedCookiesEnabled " ] ;
2020-05-29 17:56:03 +00:00
options . automaticallyAdjustsScrollIndicatorInsets =
map [ " automaticallyAdjustsScrollIndicatorInsets " ] ;
options . accessibilityIgnoresInvertColors =
map [ " accessibilityIgnoresInvertColors " ] ;
options . decelerationRate =
2021-01-28 16:10:15 +00:00
IOSUIScrollViewDecelerationRate . fromValue ( map [ " decelerationRate " ] ) ! ;
2020-05-09 02:36:07 +00:00
options . alwaysBounceVertical = map [ " alwaysBounceVertical " ] ;
options . alwaysBounceHorizontal = map [ " alwaysBounceHorizontal " ] ;
options . scrollsToTop = map [ " scrollsToTop " ] ;
options . isPagingEnabled = map [ " isPagingEnabled " ] ;
options . maximumZoomScale = map [ " maximumZoomScale " ] ;
options . minimumZoomScale = map [ " minimumZoomScale " ] ;
2020-06-13 01:50:19 +00:00
options . contentInsetAdjustmentBehavior =
IOSUIScrollViewContentInsetAdjustmentBehavior . fromValue (
2021-01-28 16:10:15 +00:00
map [ " contentInsetAdjustmentBehavior " ] ) ! ;
2021-02-03 14:17:15 +00:00
options . isDirectionalLockEnabled = map [ " isDirectionalLockEnabled " ] ;
2021-02-04 00:43:55 +00:00
options . mediaType = map [ " mediaType " ] ;
options . pageZoom = map [ " pageZoom " ] ;
options . limitsNavigationsToAppBoundDomains = map [ " limitsNavigationsToAppBoundDomains " ] ;
2021-02-09 23:15:10 +00:00
options . useOnNavigationResponse = map [ " useOnNavigationResponse " ] ;
2019-11-04 00:39:23 +00:00
return options ;
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
IOSInAppWebViewOptions copy ( ) {
return IOSInAppWebViewOptions . fromMap ( this . toMap ( ) ) ;
}
2019-10-26 20:11:23 +00:00
}
2019-11-08 21:31:57 +00:00
///This class represents all the cross-platform [InAppBrowser] options available.
2019-12-01 11:55:06 +00:00
class InAppBrowserOptions
implements BrowserOptions , AndroidOptions , IosOptions {
2019-11-08 21:31:57 +00:00
///Set to `true` to create the browser and load the page, but not show it. Omit or set to `false` to have the browser open and load normally.
///The default value is `false`.
2019-10-26 20:11:23 +00:00
bool hidden ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `false` to hide the toolbar at the top of the WebView. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool toolbarTop ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the custom background color of the toolbar at the top.
2019-10-26 20:11:23 +00:00
String toolbarTopBackgroundColor ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool hideUrlBar ;
2019-12-01 11:55:06 +00:00
InAppBrowserOptions (
{ this . hidden = false ,
this . toolbarTop = true ,
this . toolbarTopBackgroundColor = " " ,
this . hideUrlBar = false } ) ;
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
return {
" hidden " : hidden ,
" toolbarTop " : toolbarTop ,
" toolbarTopBackgroundColor " : toolbarTopBackgroundColor ,
2019-11-04 00:39:23 +00:00
" hideUrlBar " : hideUrlBar
2019-10-26 20:11:23 +00:00
} ;
}
2019-11-04 00:39:23 +00:00
static InAppBrowserOptions fromMap ( Map < String , dynamic > map ) {
2020-05-28 23:03:45 +00:00
InAppBrowserOptions options = InAppBrowserOptions ( ) ;
2019-11-04 00:39:23 +00:00
options . hidden = map [ " hidden " ] ;
options . toolbarTop = map [ " toolbarTop " ] ;
options . toolbarTopBackgroundColor = map [ " toolbarTopBackgroundColor " ] ;
options . hideUrlBar = map [ " hideUrlBar " ] ;
return options ;
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
InAppBrowserOptions copy ( ) {
return InAppBrowserOptions . fromMap ( this . toMap ( ) ) ;
}
2019-10-26 20:11:23 +00:00
}
2019-11-08 21:31:57 +00:00
///This class represents all the Android-only [InAppBrowser] options available.
2019-10-31 02:20:07 +00:00
class AndroidInAppBrowserOptions implements BrowserOptions , AndroidOptions {
2019-11-08 21:31:57 +00:00
///Set to `true` if you want the title should be displayed. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool hideTitleBar ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the action bar's title.
String toolbarTopFixedTitle ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `false` to not close the InAppBrowser when the user click on the back button and the WebView cannot go back to the history. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool closeOnCannotGoBack ;
2019-12-01 11:55:06 +00:00
2020-05-09 02:36:07 +00:00
///Set to `false` to hide the progressz bar at the bottom of the toolbar at the top. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool progressBar ;
2019-12-01 11:55:06 +00:00
AndroidInAppBrowserOptions (
2020-08-27 15:05:47 +00:00
{ this . hideTitleBar = false ,
2019-12-01 11:55:06 +00:00
this . toolbarTopFixedTitle = " " ,
this . closeOnCannotGoBack = true ,
this . progressBar = true } ) ;
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
return {
" hideTitleBar " : hideTitleBar ,
2019-11-08 21:31:57 +00:00
" toolbarTopFixedTitle " : toolbarTopFixedTitle ,
2019-10-26 20:11:23 +00:00
" closeOnCannotGoBack " : closeOnCannotGoBack ,
" progressBar " : progressBar ,
} ;
}
2019-11-04 00:39:23 +00:00
static AndroidInAppBrowserOptions fromMap ( Map < String , dynamic > map ) {
2020-05-28 23:03:45 +00:00
AndroidInAppBrowserOptions options = AndroidInAppBrowserOptions ( ) ;
2019-11-04 00:39:23 +00:00
options . hideTitleBar = map [ " hideTitleBar " ] ;
2019-11-08 21:31:57 +00:00
options . toolbarTopFixedTitle = map [ " toolbarTopFixedTitle " ] ;
2019-11-04 00:39:23 +00:00
options . closeOnCannotGoBack = map [ " closeOnCannotGoBack " ] ;
options . progressBar = map [ " progressBar " ] ;
return options ;
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
AndroidInAppBrowserOptions copy ( ) {
return AndroidInAppBrowserOptions . fromMap ( this . toMap ( ) ) ;
}
2019-10-26 20:11:23 +00:00
}
2019-11-08 21:31:57 +00:00
///This class represents all the iOS-only [InAppBrowser] options available.
2019-12-16 22:58:10 +00:00
class IOSInAppBrowserOptions implements BrowserOptions , IosOptions {
2019-11-08 21:31:57 +00:00
///Set to `false` to hide the toolbar at the bottom of the WebView. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool toolbarBottom ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the custom background color of the toolbar at the bottom.
2019-10-26 20:11:23 +00:00
String toolbarBottomBackgroundColor ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool toolbarBottomTranslucent ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the custom text for the close button.
2019-10-26 20:11:23 +00:00
String closeButtonCaption ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the custom color for the close button.
2019-10-26 20:11:23 +00:00
String closeButtonColor ;
2019-12-01 11:55:06 +00:00
2019-12-18 00:56:21 +00:00
///Set the custom modal presentation style when presenting the WebView. The default value is [IOSUIModalPresentationStyle.FULL_SCREEN].
IOSUIModalPresentationStyle presentationStyle ;
2019-12-01 11:55:06 +00:00
2019-12-18 00:56:21 +00:00
///Set to the custom transition style when presenting the WebView. The default value is [IOSUIModalTransitionStyle.COVER_VERTICAL].
IOSUIModalTransitionStyle transitionStyle ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool spinner ;
2019-12-16 22:58:10 +00:00
IOSInAppBrowserOptions (
2019-12-01 11:55:06 +00:00
{ this . toolbarBottom = true ,
this . toolbarBottomBackgroundColor = " " ,
this . toolbarBottomTranslucent = true ,
this . closeButtonCaption = " " ,
this . closeButtonColor = " " ,
2019-12-18 00:56:21 +00:00
this . presentationStyle = IOSUIModalPresentationStyle . FULL_SCREEN ,
this . transitionStyle = IOSUIModalTransitionStyle . COVER_VERTICAL ,
2019-12-01 11:55:06 +00:00
this . spinner = true } ) ;
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
return {
" toolbarBottom " : toolbarBottom ,
" toolbarBottomBackgroundColor " : toolbarBottomBackgroundColor ,
" toolbarBottomTranslucent " : toolbarBottomTranslucent ,
" closeButtonCaption " : closeButtonCaption ,
" closeButtonColor " : closeButtonColor ,
2019-10-29 14:27:50 +00:00
" presentationStyle " : presentationStyle . toValue ( ) ,
" transitionStyle " : transitionStyle . toValue ( ) ,
2019-11-04 00:39:23 +00:00
" spinner " : spinner
2019-10-26 20:11:23 +00:00
} ;
}
2019-12-16 22:58:10 +00:00
static IOSInAppBrowserOptions fromMap ( Map < String , dynamic > map ) {
2020-05-28 23:03:45 +00:00
IOSInAppBrowserOptions options = IOSInAppBrowserOptions ( ) ;
2019-11-04 00:39:23 +00:00
options . toolbarBottom = map [ " toolbarBottom " ] ;
options . toolbarBottomBackgroundColor = map [ " toolbarBottomBackgroundColor " ] ;
options . toolbarBottomTranslucent = map [ " toolbarBottomTranslucent " ] ;
options . closeButtonCaption = map [ " closeButtonCaption " ] ;
options . closeButtonColor = map [ " closeButtonColor " ] ;
2019-12-01 11:55:06 +00:00
options . presentationStyle =
2021-01-28 16:10:15 +00:00
IOSUIModalPresentationStyle . fromValue ( map [ " presentationStyle " ] ) ! ;
2019-12-01 11:55:06 +00:00
options . transitionStyle =
2021-01-28 16:10:15 +00:00
IOSUIModalTransitionStyle . fromValue ( map [ " transitionStyle " ] ) ! ;
2019-11-04 00:39:23 +00:00
options . spinner = map [ " spinner " ] ;
return options ;
2019-10-27 03:35:05 +00:00
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
IOSInAppBrowserOptions copy ( ) {
return IOSInAppBrowserOptions . fromMap ( this . toMap ( ) ) ;
}
2019-10-27 03:35:05 +00:00
}
2019-11-08 21:31:57 +00:00
///This class represents all the Android-only [ChromeSafariBrowser] options available.
2019-12-01 11:55:06 +00:00
class AndroidChromeCustomTabsOptions
implements ChromeSafariBrowserOptions , AndroidOptions {
2019-12-18 00:56:21 +00:00
///Set to `false` if you don't want the default share item to the menu. The default value is `true`.
bool addDefaultShareMenuItem ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
2019-10-26 20:11:23 +00:00
bool showTitle ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the custom background color of the toolbar.
2019-10-26 20:11:23 +00:00
String toolbarBackgroundColor ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool enableUrlBarHiding ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to enable Instant Apps. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool instantAppsEnabled ;
2019-12-18 00:56:21 +00:00
///Set an explicit application package name that limits
///the components this Intent will resolve to. If left to the default
///value of null, all components in all applications will considered.
///If non-null, the Intent can only match the components in the given
///application package.
2021-01-28 16:10:15 +00:00
String ? packageName ;
2019-12-18 00:56:21 +00:00
///Set to `true` to enable Keep Alive. The default value is `false`.
bool keepAliveEnabled ;
2019-12-01 11:55:06 +00:00
AndroidChromeCustomTabsOptions (
2019-12-18 00:56:21 +00:00
{ this . addDefaultShareMenuItem = true ,
2019-12-01 11:55:06 +00:00
this . showTitle = true ,
this . toolbarBackgroundColor = " " ,
this . enableUrlBarHiding = false ,
2019-12-18 00:56:21 +00:00
this . instantAppsEnabled = false ,
this . packageName ,
this . keepAliveEnabled = false } ) ;
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
return {
2019-12-18 00:56:21 +00:00
" addDefaultShareMenuItem " : addDefaultShareMenuItem ,
2019-10-26 20:11:23 +00:00
" showTitle " : showTitle ,
" toolbarBackgroundColor " : toolbarBackgroundColor ,
" enableUrlBarHiding " : enableUrlBarHiding ,
2019-12-18 00:56:21 +00:00
" instantAppsEnabled " : instantAppsEnabled ,
" packageName " : packageName ,
" keepAliveEnabled " : keepAliveEnabled
2019-10-26 20:11:23 +00:00
} ;
}
2019-11-04 00:39:23 +00:00
static AndroidChromeCustomTabsOptions fromMap ( Map < String , dynamic > map ) {
2019-12-01 11:55:06 +00:00
AndroidChromeCustomTabsOptions options =
new AndroidChromeCustomTabsOptions ( ) ;
2019-12-18 00:56:21 +00:00
options . addDefaultShareMenuItem = map [ " addDefaultShareMenuItem " ] ;
2019-11-04 00:39:23 +00:00
options . showTitle = map [ " showTitle " ] ;
options . toolbarBackgroundColor = map [ " toolbarBackgroundColor " ] ;
options . enableUrlBarHiding = map [ " enableUrlBarHiding " ] ;
options . instantAppsEnabled = map [ " instantAppsEnabled " ] ;
2019-12-18 00:56:21 +00:00
options . packageName = map [ " packageName " ] ;
options . keepAliveEnabled = map [ " keepAliveEnabled " ] ;
2019-11-04 00:39:23 +00:00
return options ;
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
AndroidChromeCustomTabsOptions copy ( ) {
return AndroidChromeCustomTabsOptions . fromMap ( this . toMap ( ) ) ;
}
2019-10-26 20:11:23 +00:00
}
2019-11-08 21:31:57 +00:00
///This class represents all the iOS-only [ChromeSafariBrowser] options available.
2019-12-16 22:58:10 +00:00
class IOSSafariOptions implements ChromeSafariBrowserOptions , IosOptions {
2019-11-08 21:31:57 +00:00
///Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool entersReaderIfAvailable ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set to `true` to enable bar collapsing. The default value is `false`.
2019-10-26 20:11:23 +00:00
bool barCollapsingEnabled ;
2019-12-01 11:55:06 +00:00
2019-12-18 00:56:21 +00:00
///Set the custom style for the dismiss button. The default value is [IOSSafariDismissButtonStyle.DONE].
2019-11-09 22:35:18 +00:00
///
///**NOTE**: available on iOS 11.0+.
2019-12-18 00:56:21 +00:00
IOSSafariDismissButtonStyle dismissButtonStyle ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the custom background color of the navigation bar and the toolbar.
2019-11-09 22:35:18 +00:00
///
///**NOTE**: available on iOS 10.0+.
2019-10-26 20:11:23 +00:00
String preferredBarTintColor ;
2019-12-01 11:55:06 +00:00
2019-11-08 21:31:57 +00:00
///Set the custom color of the control buttons on the navigation bar and the toolbar.
2019-11-09 22:35:18 +00:00
///
///**NOTE**: available on iOS 10.0+.
2019-10-26 20:11:23 +00:00
String preferredControlTintColor ;
2019-12-01 11:55:06 +00:00
2019-12-18 00:56:21 +00:00
///Set the custom modal presentation style when presenting the WebView. The default value is [IOSUIModalPresentationStyle.FULL_SCREEN].
IOSUIModalPresentationStyle presentationStyle ;
2019-12-01 11:55:06 +00:00
2019-12-18 00:56:21 +00:00
///Set to the custom transition style when presenting the WebView. The default value is [IOSUIModalTransitionStyle.COVER_VERTICAL].
IOSUIModalTransitionStyle transitionStyle ;
2019-10-26 20:11:23 +00:00
2019-12-16 22:58:10 +00:00
IOSSafariOptions (
2019-12-01 11:55:06 +00:00
{ this . entersReaderIfAvailable = false ,
this . barCollapsingEnabled = false ,
2019-12-18 00:56:21 +00:00
this . dismissButtonStyle = IOSSafariDismissButtonStyle . DONE ,
2019-12-01 11:55:06 +00:00
this . preferredBarTintColor = " " ,
this . preferredControlTintColor = " " ,
2019-12-18 00:56:21 +00:00
this . presentationStyle = IOSUIModalPresentationStyle . FULL_SCREEN ,
this . transitionStyle = IOSUIModalTransitionStyle . COVER_VERTICAL } ) ;
2019-10-26 20:11:23 +00:00
@ override
Map < String , dynamic > toMap ( ) {
return {
" entersReaderIfAvailable " : entersReaderIfAvailable ,
" barCollapsingEnabled " : barCollapsingEnabled ,
2019-10-29 14:27:50 +00:00
" dismissButtonStyle " : dismissButtonStyle . toValue ( ) ,
2019-10-26 20:11:23 +00:00
" preferredBarTintColor " : preferredBarTintColor ,
" preferredControlTintColor " : preferredControlTintColor ,
2019-10-29 14:27:50 +00:00
" presentationStyle " : presentationStyle . toValue ( ) ,
2019-11-04 00:39:23 +00:00
" transitionStyle " : transitionStyle . toValue ( )
2019-10-26 20:11:23 +00:00
} ;
}
2019-11-04 00:39:23 +00:00
2019-12-16 22:58:10 +00:00
static IOSSafariOptions fromMap ( Map < String , dynamic > map ) {
2020-05-28 23:03:45 +00:00
IOSSafariOptions options = IOSSafariOptions ( ) ;
2019-11-04 00:39:23 +00:00
options . entersReaderIfAvailable = map [ " entersReaderIfAvailable " ] ;
options . barCollapsingEnabled = map [ " barCollapsingEnabled " ] ;
2019-12-01 11:55:06 +00:00
options . dismissButtonStyle =
2021-01-28 16:10:15 +00:00
IOSSafariDismissButtonStyle . fromValue ( map [ " dismissButtonStyle " ] ) ! ;
2019-11-04 00:39:23 +00:00
options . preferredBarTintColor = map [ " preferredBarTintColor " ] ;
options . preferredControlTintColor = map [ " preferredControlTintColor " ] ;
2019-12-01 11:55:06 +00:00
options . presentationStyle =
2021-01-28 16:10:15 +00:00
IOSUIModalPresentationStyle . fromValue ( map [ " presentationStyle " ] ) ! ;
2019-12-01 11:55:06 +00:00
options . transitionStyle =
2021-01-28 16:10:15 +00:00
IOSUIModalTransitionStyle . fromValue ( map [ " transitionStyle " ] ) ! ;
2019-11-04 00:39:23 +00:00
return options ;
}
2020-05-29 17:56:03 +00:00
@ override
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
@ override
String toString ( ) {
return toMap ( ) . toString ( ) ;
}
2020-06-13 01:50:19 +00:00
@ override
IOSSafariOptions copy ( ) {
return IOSSafariOptions . fromMap ( this . toMap ( ) ) ;
}
2019-12-01 11:55:06 +00:00
}