2019-11-02 03:16:47 +00:00
import ' dart:async ' ;
2019-10-31 22:09:54 +00:00
import ' dart:typed_data ' ;
2019-10-26 02:42:50 +00:00
import ' package:uuid/uuid.dart ' ;
import ' package:flutter/services.dart ' ;
2019-11-10 13:11:30 +00:00
import ' package:flutter/foundation.dart ' ;
2019-11-04 00:39:23 +00:00
import ' webview_options.dart ' ;
2019-10-26 02:42:50 +00:00
var uuidGenerator = new Uuid ( ) ;
typedef Future < dynamic > ListenerCallback ( MethodCall call ) ;
///This type represents a callback, added with [addJavaScriptHandler], that listens to post messages sent from JavaScript.
///
///The Android implementation uses [addJavascriptInterface](https://developer.android.com/reference/android/webkit/WebView#addJavascriptInterface(java.lang.Object,%20java.lang.String)).
///The iOS implementation uses [addScriptMessageHandler](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537172-addscriptmessagehandler?language=objc)
///
///The JavaScript function that can be used to call the handler is `window.flutter_inappbrowser.callHandler(handlerName <String>, ...args);`, where `args` are [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
///The `args` will be stringified automatically using `JSON.stringify(args)` method and then they will be decoded on the Dart side.
///
///Also, a [JavaScriptHandlerCallback] can return json data to the JavaScript side.
///In this case, simply return data that you want to send and it will be automatically json encoded using [jsonEncode] from the `dart:convert` library.
typedef dynamic JavaScriptHandlerCallback ( List < dynamic > arguments ) ;
2019-10-29 14:27:50 +00:00
///Class representing the level of a console message.
class ConsoleMessageLevel {
final int _value ;
const ConsoleMessageLevel . _internal ( this . _value ) ;
static ConsoleMessageLevel fromValue ( int value ) {
2019-11-04 00:39:23 +00:00
if ( value ! = null & & value > = 0 & & value < = 4 )
2019-10-29 14:27:50 +00:00
return ConsoleMessageLevel . _internal ( value ) ;
return null ;
}
toValue ( ) = > _value ;
static const TIP = const ConsoleMessageLevel . _internal ( 0 ) ;
static const LOG = const ConsoleMessageLevel . _internal ( 1 ) ;
static const WARNING = const ConsoleMessageLevel . _internal ( 2 ) ;
static const ERROR = const ConsoleMessageLevel . _internal ( 3 ) ;
static const DEBUG = const ConsoleMessageLevel . _internal ( 4 ) ;
2019-10-26 02:42:50 +00:00
}
///Public class representing a resource response of the [InAppBrowser] WebView.
///It is used by the method [InAppBrowser.onLoadResource()].
2019-11-04 00:39:23 +00:00
class LoadedResource {
2019-10-26 02:42:50 +00:00
2019-10-26 20:11:23 +00:00
///A string representing the type of resource.
String initiatorType ;
///Resource URL.
2019-10-26 02:42:50 +00:00
String url ;
2019-10-26 20:11:23 +00:00
///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) for the time a resource fetch started.
double startTime ;
///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource.
double duration ;
2019-10-26 02:42:50 +00:00
2019-11-10 13:11:30 +00:00
LoadedResource ( { this . initiatorType , this . url , this . startTime , this . duration } ) ;
2019-11-04 00:39:23 +00:00
}
2019-11-05 02:44:22 +00:00
///Initial [data] as a content for an [InAppWebView] instance, using [baseUrl] as the base URL for it.
///The [mimeType] property specifies the format of the data.
///The [encoding] property specifies the encoding of the data.
class InAppWebViewInitialData {
String data ;
String mimeType ;
String encoding ;
String baseUrl ;
2019-11-10 13:11:30 +00:00
InAppWebViewInitialData ( { @ required this . data , this . mimeType = " text/html " , this . encoding = " utf8 " , this . baseUrl = " about:blank " } ) ;
2019-11-05 02:44:22 +00:00
Map < String , String > toMap ( ) {
return {
" data " : data ,
" mimeType " : mimeType ,
" encoding " : encoding ,
" baseUrl " : baseUrl
} ;
}
}
2019-11-04 00:39:23 +00:00
/ *
///Public class representing a resource request of the WebView.
///It is used by the event [shouldInterceptRequest()].
class WebResourceRequest {
String url ;
Map < String , String > headers ;
String method ;
WebResourceRequest ( { @ required this . url , @ required this . headers , @ required this . method } ) ;
2019-10-26 02:42:50 +00:00
}
2019-11-04 00:39:23 +00:00
///Public class representing a resource response of the WebView.
///It is used by the event [shouldInterceptRequest()].
class WebResourceResponse {
String contentType ;
String contentEncoding ;
Uint8List data ;
WebResourceResponse ( { @ required this . contentType , this . contentEncoding = " utf-8 " , @ required this . data } ) : assert ( contentType ! = null & & contentEncoding ! = null & & data ! = null ) ;
Map < String , dynamic > toMap ( ) {
return {
" contentType " : contentType ,
" contentEncoding " : contentEncoding ,
" data " : data
} ;
}
} * /
///Public class representing the response returned by the [onLoadResourceCustomScheme()] event.
2019-10-26 02:42:50 +00:00
///It allows to load a specific resource. The resource data must be encoded to `base64`.
class CustomSchemeResponse {
2019-10-26 20:11:23 +00:00
///Data enconded to 'base64'.
2019-11-04 00:39:23 +00:00
Uint8List data ;
2019-10-26 20:11:23 +00:00
///Content-Type of the data, such as `image/png`.
2019-10-26 02:42:50 +00:00
String contentType ;
2019-10-26 20:11:23 +00:00
///Content-Enconding of the data, such as `utf-8`.
2019-10-26 02:42:50 +00:00
String contentEnconding ;
2019-11-10 13:11:30 +00:00
CustomSchemeResponse ( { @ required this . data , @ required this . contentType , this . contentEnconding = ' utf-8 ' } ) ;
2019-10-26 02:42:50 +00:00
Map < String , dynamic > toJson ( ) {
return {
' content-type ' : this . contentType ,
' content-encoding ' : this . contentEnconding ,
2019-11-04 00:39:23 +00:00
' data ' : this . data
2019-10-26 02:42:50 +00:00
} ;
}
}
///Public class representing a JavaScript console message from WebCore.
///This could be a issued by a call to one of the console logging functions (e.g. console.log('...')) or a JavaScript error on the page.
///
2019-11-08 21:31:57 +00:00
///To receive notifications of these messages, use the [onConsoleMessage] event.
2019-10-26 02:42:50 +00:00
class ConsoleMessage {
2019-11-10 13:11:30 +00:00
String sourceURL ;
int lineNumber ;
String message ;
ConsoleMessageLevel messageLevel ;
2019-10-26 02:42:50 +00:00
2019-11-10 13:11:30 +00:00
ConsoleMessage ( { this . sourceURL = " " , this . lineNumber = 1 , this . message = " " , this . messageLevel = ConsoleMessageLevel . LOG } ) ;
2019-10-26 02:42:50 +00:00
}
2019-10-26 20:11:23 +00:00
///WebHistory class.
///
///This class contains a snapshot of the current back/forward list for a WebView.
class WebHistory {
///List of all [WebHistoryItem]s.
2019-11-10 13:11:30 +00:00
List < WebHistoryItem > list ;
2019-10-26 20:11:23 +00:00
///Index of the current [WebHistoryItem].
int currentIndex ;
2019-11-10 13:11:30 +00:00
WebHistory ( { this . list , this . currentIndex } ) ;
2019-10-26 20:11:23 +00:00
}
///WebHistoryItem class.
///
///A convenience class for accessing fields in an entry in the back/forward list of a WebView. Each WebHistoryItem is a snapshot of the requested history item.
class WebHistoryItem {
///Original url of this history item.
String originalUrl ;
///Document title of this history item.
String title ;
///Url of this history item.
String url ;
///0-based position index in the back-forward [WebHistory.list].
int index ;
///Position offset respect to the currentIndex of the back-forward [WebHistory.list].
int offset ;
2019-11-10 13:11:30 +00:00
WebHistoryItem ( { this . originalUrl , this . title , this . url , this . index , this . offset } ) ;
2019-10-26 20:11:23 +00:00
}
2019-10-28 03:58:25 +00:00
///GeolocationPermissionPromptResponse class.
///
///Class used by the host application to set the Geolocation permission state for an origin during the [onGeolocationPermissionsShowPrompt] event.
class GeolocationPermissionShowPromptResponse {
///The origin for which permissions are set.
String origin ;
///Whether or not the origin should be allowed to use the Geolocation API.
bool allow ;
///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView
bool retain ;
2019-11-10 13:11:30 +00:00
GeolocationPermissionShowPromptResponse ( { this . origin , this . allow , this . retain } ) ;
2019-10-28 03:58:25 +00:00
Map < String , dynamic > toMap ( ) {
return {
" origin " : origin ,
" allow " : allow ,
" retain " : retain
} ;
}
}
2019-11-08 21:31:57 +00:00
///JsAlertResponseAction class used by [JsAlertResponse] class.
2019-10-29 02:03:50 +00:00
class JsAlertResponseAction {
final int _value ;
const JsAlertResponseAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
static const CONFIRM = const JsAlertResponseAction . _internal ( 0 ) ;
}
2019-11-08 21:31:57 +00:00
///JsAlertResponse class represents the response used by the [onJsAlert] event to control a JavaScript alert dialog.
2019-10-29 02:03:50 +00:00
class JsAlertResponse {
2019-11-08 21:31:57 +00:00
///Message to be displayed in the window.
2019-10-29 02:03:50 +00:00
String message ;
2019-11-08 21:31:57 +00:00
///Title of the confirm button.
2019-10-29 02:03:50 +00:00
String confirmButtonTitle ;
2019-11-08 21:31:57 +00:00
///Whether the client will handle the alert dialog.
2019-10-29 02:03:50 +00:00
bool handledByClient ;
2019-11-08 21:31:57 +00:00
///Action used to confirm that the user hit confirm button.
2019-10-29 02:03:50 +00:00
JsAlertResponseAction action ;
JsAlertResponse ( { this . message = " " , this . handledByClient = false , this . confirmButtonTitle = " " , this . action = JsAlertResponseAction . CONFIRM } ) ;
Map < String , dynamic > toMap ( ) {
return {
" message " : message ,
" confirmButtonTitle " : confirmButtonTitle ,
" handledByClient " : handledByClient ,
" action " : action ? . toValue ( )
} ;
}
}
2019-11-08 21:31:57 +00:00
///JsConfirmResponseAction class used by [JsConfirmResponse] class.
2019-10-29 02:03:50 +00:00
class JsConfirmResponseAction {
final int _value ;
const JsConfirmResponseAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
static const CONFIRM = const JsConfirmResponseAction . _internal ( 0 ) ;
static const CANCEL = const JsConfirmResponseAction . _internal ( 1 ) ;
}
2019-11-08 21:31:57 +00:00
///JsConfirmResponse class represents the response used by the [onJsConfirm] event to control a JavaScript confirm dialog.
2019-10-29 02:03:50 +00:00
class JsConfirmResponse {
2019-11-08 21:31:57 +00:00
///Message to be displayed in the window.
2019-10-29 02:03:50 +00:00
String message ;
2019-11-08 21:31:57 +00:00
///Title of the confirm button.
2019-10-29 02:03:50 +00:00
String confirmButtonTitle ;
2019-11-08 21:31:57 +00:00
///Title of the cancel button.
2019-10-29 02:03:50 +00:00
String cancelButtonTitle ;
2019-11-08 21:31:57 +00:00
///Whether the client will handle the confirm dialog.
2019-10-29 02:03:50 +00:00
bool handledByClient ;
2019-11-08 21:31:57 +00:00
///Action used to confirm that the user hit confirm or cancel button.
2019-10-29 02:03:50 +00:00
JsConfirmResponseAction action ;
JsConfirmResponse ( { this . message = " " , this . handledByClient = false , this . confirmButtonTitle = " " , this . cancelButtonTitle = " " , this . action = JsConfirmResponseAction . CANCEL } ) ;
Map < String , dynamic > toMap ( ) {
return {
" message " : message ,
" confirmButtonTitle " : confirmButtonTitle ,
" cancelButtonTitle " : cancelButtonTitle ,
" handledByClient " : handledByClient ,
" action " : action ? . toValue ( )
} ;
}
}
2019-11-08 21:31:57 +00:00
///JsPromptResponseAction class used by [JsPromptResponse] class.
2019-10-29 02:03:50 +00:00
class JsPromptResponseAction {
final int _value ;
const JsPromptResponseAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
static const CONFIRM = const JsPromptResponseAction . _internal ( 0 ) ;
static const CANCEL = const JsPromptResponseAction . _internal ( 1 ) ;
}
2019-11-08 21:31:57 +00:00
///JsPromptResponse class represents the response used by the [onJsPrompt] event to control a JavaScript prompt dialog.
2019-10-29 02:03:50 +00:00
class JsPromptResponse {
2019-11-08 21:31:57 +00:00
///Message to be displayed in the window.
2019-10-29 02:03:50 +00:00
String message ;
2019-11-08 21:31:57 +00:00
///The default value displayed in the prompt dialog.
2019-10-29 02:03:50 +00:00
String defaultValue ;
2019-11-08 21:31:57 +00:00
///Title of the confirm button.
2019-10-29 02:03:50 +00:00
String confirmButtonTitle ;
2019-11-08 21:31:57 +00:00
///Title of the cancel button.
2019-10-29 02:03:50 +00:00
String cancelButtonTitle ;
2019-11-08 21:31:57 +00:00
///Whether the client will handle the prompt dialog.
2019-10-29 02:03:50 +00:00
bool handledByClient ;
2019-11-08 21:31:57 +00:00
///Value of the prompt dialog.
2019-10-29 02:03:50 +00:00
String value ;
2019-11-08 21:31:57 +00:00
///Action used to confirm that the user hit confirm or cancel button.
2019-10-29 02:03:50 +00:00
JsPromptResponseAction action ;
JsPromptResponse ( { this . message = " " , this . defaultValue = " " , this . handledByClient = false , this . confirmButtonTitle = " " , this . cancelButtonTitle = " " , this . value , this . action = JsPromptResponseAction . CANCEL } ) ;
Map < String , dynamic > toMap ( ) {
return {
" message " : message ,
" defaultValue " : defaultValue ,
" confirmButtonTitle " : confirmButtonTitle ,
" cancelButtonTitle " : cancelButtonTitle ,
" handledByClient " : handledByClient ,
" value " : value ,
" action " : action ? . toValue ( )
} ;
}
}
2019-11-09 22:35:18 +00:00
///SafeBrowsingThreat class represents the reason the resource was caught by Safe Browsing.
2019-10-29 14:27:50 +00:00
class SafeBrowsingThreat {
final int _value ;
const SafeBrowsingThreat . _internal ( this . _value ) ;
static SafeBrowsingThreat fromValue ( int value ) {
2019-11-04 00:39:23 +00:00
if ( value ! = null & & value > = 0 & & value < = 4 )
2019-10-29 14:27:50 +00:00
return SafeBrowsingThreat . _internal ( value ) ;
return null ;
}
toValue ( ) = > _value ;
static const SAFE_BROWSING_THREAT_UNKNOWN = const SafeBrowsingThreat . _internal ( 0 ) ;
static const SAFE_BROWSING_THREAT_MALWARE = const SafeBrowsingThreat . _internal ( 1 ) ;
static const SAFE_BROWSING_THREAT_PHISHING = const SafeBrowsingThreat . _internal ( 2 ) ;
static const SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE = const SafeBrowsingThreat . _internal ( 3 ) ;
static const SAFE_BROWSING_THREAT_BILLING = const SafeBrowsingThreat . _internal ( 4 ) ;
}
2019-11-08 21:31:57 +00:00
///SafeBrowsingResponseAction class used by [SafeBrowsingResponse] class.
2019-10-29 14:27:50 +00:00
class SafeBrowsingResponseAction {
final int _value ;
const SafeBrowsingResponseAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Act as if the user clicked the "back to safety" button.
2019-10-29 14:27:50 +00:00
static const BACK_TO_SAFETY = const SafeBrowsingResponseAction . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Act as if the user clicked the "visit this unsafe site" button.
2019-10-29 14:27:50 +00:00
static const PROCEED = const SafeBrowsingResponseAction . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Display the default interstitial.
2019-10-29 14:27:50 +00:00
static const SHOW_INTERSTITIAL = const SafeBrowsingResponseAction . _internal ( 2 ) ;
}
2019-10-31 02:20:07 +00:00
2019-11-09 22:35:18 +00:00
///SafeBrowsingResponse class represents the response used by the [onSafeBrowsingHit] event.
///It is used to indicate an action to take when hitting a malicious URL.
2019-10-29 14:27:50 +00:00
class SafeBrowsingResponse {
2019-11-09 22:35:18 +00:00
///If reporting is enabled, all reports will be sent according to the privacy policy referenced by [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl].
2019-10-29 14:27:50 +00:00
bool report ;
2019-11-09 22:35:18 +00:00
///Indicate the [SafeBrowsingResponseAction] to take when hitting a malicious URL.
2019-10-29 14:27:50 +00:00
SafeBrowsingResponseAction action ;
SafeBrowsingResponse ( { this . report = true , this . action = SafeBrowsingResponseAction . SHOW_INTERSTITIAL } ) ;
Map < String , dynamic > toMap ( ) {
return {
" report " : report ,
" action " : action ? . toValue ( )
} ;
}
}
2019-11-09 22:35:18 +00:00
///HttpAuthResponseAction class used by [HttpAuthResponse] class.
2019-10-29 16:51:55 +00:00
class HttpAuthResponseAction {
final int _value ;
const HttpAuthResponseAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Instructs the WebView to cancel the authentication request.
2019-10-29 16:51:55 +00:00
static const CANCEL = const HttpAuthResponseAction . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Instructs the WebView to proceed with the authentication with the given credentials.
2019-10-29 16:51:55 +00:00
static const PROCEED = const HttpAuthResponseAction . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Uses the credentials stored for the current host.
2019-10-31 02:20:07 +00:00
static const USE_SAVED_HTTP_AUTH_CREDENTIALS = const HttpAuthResponseAction . _internal ( 2 ) ;
2019-10-29 16:51:55 +00:00
}
2019-11-09 22:35:18 +00:00
///HttpAuthResponse class represents the response used by the [onReceivedHttpAuthRequest] event.
2019-10-29 16:51:55 +00:00
class HttpAuthResponse {
2019-11-09 22:35:18 +00:00
///Represents the username used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED]
2019-10-29 16:51:55 +00:00
String username ;
2019-11-09 22:35:18 +00:00
///Represents the password used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED]
2019-10-29 16:51:55 +00:00
String password ;
2019-11-09 22:35:18 +00:00
///Indicate if the given credentials need to be saved permanently.
2019-10-29 16:51:55 +00:00
bool permanentPersistence ;
2019-11-09 22:35:18 +00:00
///Indicate the [HttpAuthResponseAction] to take in response of the authentication challenge.
2019-10-29 16:51:55 +00:00
HttpAuthResponseAction action ;
HttpAuthResponse ( { this . username = " " , this . password = " " , this . permanentPersistence = false , this . action = HttpAuthResponseAction . CANCEL } ) ;
Map < String , dynamic > toMap ( ) {
return {
" username " : username ,
" password " : password ,
" permanentPersistence " : permanentPersistence ,
" action " : action ? . toValue ( )
} ;
}
}
2019-11-09 22:35:18 +00:00
///HttpAuthChallenge class represents the challenge of the [onReceivedHttpAuthRequest] event.
///It provides all the information about the challenge.
2019-10-31 02:20:07 +00:00
class HttpAuthChallenge {
2019-11-09 22:35:18 +00:00
///A count of previous failed authentication attempts.
2019-10-31 02:20:07 +00:00
int previousFailureCount ;
2019-11-09 22:35:18 +00:00
///The protection space requiring authentication.
2019-10-31 02:20:07 +00:00
ProtectionSpace protectionSpace ;
HttpAuthChallenge ( { @ required this . previousFailureCount , @ required this . protectionSpace } ) : assert ( previousFailureCount ! = null & & protectionSpace ! = null ) ;
}
2019-11-09 22:35:18 +00:00
///ProtectionSpace class represents a protection space requiring authentication.
2019-10-31 02:20:07 +00:00
class ProtectionSpace {
2019-11-09 22:35:18 +00:00
///The hostname of the server.
2019-10-31 02:20:07 +00:00
String host ;
2019-11-09 22:35:18 +00:00
///The protocol of the server - e.g. "http", "ftp", "https".
2019-10-31 02:20:07 +00:00
String protocol ;
2019-11-09 22:35:18 +00:00
///A string indicating a protocol-specific subdivision of a single host.
///For http and https, this maps to the realm string in http authentication challenges.
///For many other protocols it is unused.
2019-10-31 02:20:07 +00:00
String realm ;
2019-11-09 22:35:18 +00:00
///The port of the server.
2019-10-31 02:20:07 +00:00
int port ;
ProtectionSpace ( { @ required this . host , @ required this . protocol , this . realm , this . port } ) : assert ( host ! = null & & protocol ! = null ) ;
}
2019-11-09 22:35:18 +00:00
///HttpAuthCredential represents the credentials of an http authentication.
///It is used by the [HttpAuthCredentialDatabase] class.
2019-10-31 02:20:07 +00:00
class HttpAuthCredential {
2019-11-09 22:35:18 +00:00
///Represents the username.
2019-10-31 02:20:07 +00:00
String username ;
2019-11-09 22:35:18 +00:00
///Represents the password.
2019-10-31 02:20:07 +00:00
String password ;
HttpAuthCredential ( { @ required this . username , @ required this . password } ) : assert ( username ! = null & & password ! = null ) ;
}
2019-11-09 22:35:18 +00:00
///ServerTrustAuthResponseAction class used by [ServerTrustAuthResponse] class.
2019-10-31 22:09:54 +00:00
class ServerTrustAuthResponseAction {
final int _value ;
const ServerTrustAuthResponseAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Instructs the WebView to cancel the authentication challenge.
2019-10-31 22:09:54 +00:00
static const CANCEL = const ServerTrustAuthResponseAction . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Instructs the WebView to proceed with the authentication challenge.
2019-10-31 22:09:54 +00:00
static const PROCEED = const ServerTrustAuthResponseAction . _internal ( 1 ) ;
}
2019-11-09 22:35:18 +00:00
///ServerTrustAuthResponse class represents the response used by the [onReceivedServerTrustAuthRequest] event.
2019-10-31 22:09:54 +00:00
class ServerTrustAuthResponse {
2019-11-09 22:35:18 +00:00
///Indicate the [ServerTrustAuthResponseAction] to take in response of the server trust authentication challenge.
2019-10-31 22:09:54 +00:00
ServerTrustAuthResponseAction action ;
ServerTrustAuthResponse ( { this . action = ServerTrustAuthResponseAction . CANCEL } ) ;
Map < String , dynamic > toMap ( ) {
return {
" action " : action ? . toValue ( )
} ;
}
}
2019-11-09 22:35:18 +00:00
///ServerTrustChallenge class represents the challenge of the [onReceivedServerTrustAuthRequest] event.
///It provides all the information about the challenge.
2019-10-31 22:09:54 +00:00
class ServerTrustChallenge {
2019-11-09 22:35:18 +00:00
///The protection space requiring authentication.
2019-10-31 22:09:54 +00:00
ProtectionSpace protectionSpace ;
2019-11-09 22:35:18 +00:00
///The primary error associated to the server SSL certificate.
///
///**NOTE**: on iOS this value is always -1.
2019-10-31 22:09:54 +00:00
int error ;
2019-11-09 22:35:18 +00:00
///The message associated to the [error].
///
///**NOTE**: on iOS this value is always an empty string.
2019-10-31 22:09:54 +00:00
String message ;
2019-11-09 22:35:18 +00:00
///The `X509Certificate` used to create the server SSL certificate.
2019-10-31 22:09:54 +00:00
Uint8List serverCertificate ;
ServerTrustChallenge ( { @ required this . protectionSpace , @ required this . error , this . message , this . serverCertificate } ) : assert ( protectionSpace ! = null & & error ! = null ) ;
}
2019-11-09 22:35:18 +00:00
///ClientCertResponseAction class used by [ClientCertResponse] class.
2019-10-31 22:09:54 +00:00
class ClientCertResponseAction {
final int _value ;
const ClientCertResponseAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Cancel this request.
2019-10-31 22:09:54 +00:00
static const CANCEL = const ClientCertResponseAction . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Proceed with the specified certificate.
2019-10-31 22:09:54 +00:00
static const PROCEED = const ClientCertResponseAction . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Ignore the request for now.
2019-10-31 22:09:54 +00:00
static const IGNORE = const ClientCertResponseAction . _internal ( 2 ) ;
}
2019-11-09 22:35:18 +00:00
///ClientCertResponse class represents the response used by the [onReceivedClientCertRequest] event.
2019-10-31 22:09:54 +00:00
class ClientCertResponse {
2019-11-09 22:35:18 +00:00
///The file path of the certificate to use.
2019-10-31 22:09:54 +00:00
String certificatePath ;
2019-11-09 22:35:18 +00:00
///The certificate password.
2019-10-31 22:09:54 +00:00
String certificatePassword ;
2019-11-09 22:35:18 +00:00
///An Android-specific property used by Java [KeyStore](https://developer.android.com/reference/java/security/KeyStore) class to get the instance.
2019-10-31 22:09:54 +00:00
String androidKeyStoreType ;
2019-11-09 22:35:18 +00:00
///Indicate the [ClientCertResponseAction] to take in response of the client certificate challenge.
2019-10-31 22:09:54 +00:00
ClientCertResponseAction action ;
ClientCertResponse ( { this . certificatePath , this . certificatePassword = " " , this . androidKeyStoreType = " PKCS12 " , this . action = ClientCertResponseAction . CANCEL } ) {
if ( this . action = = ClientCertResponseAction . PROCEED )
assert ( certificatePath ! = null & & certificatePath . isNotEmpty ) ;
}
Map < String , dynamic > toMap ( ) {
return {
" certificatePath " : certificatePath ,
" certificatePassword " : certificatePassword ,
" androidKeyStoreType " : androidKeyStoreType ,
" action " : action ? . toValue ( )
} ;
}
}
2019-11-09 22:35:18 +00:00
///ClientCertChallenge class represents the challenge of the [onReceivedClientCertRequest] event.
///It provides all the information about the challenge.
2019-10-31 22:09:54 +00:00
class ClientCertChallenge {
2019-11-09 22:35:18 +00:00
///The protection space requiring authentication.
2019-10-31 22:09:54 +00:00
ProtectionSpace protectionSpace ;
ClientCertChallenge ( { @ required this . protectionSpace } ) : assert ( protectionSpace ! = null ) ;
}
2019-11-09 22:35:18 +00:00
///Favicon class represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method.
2019-11-02 03:16:47 +00:00
class Favicon {
2019-11-09 22:35:18 +00:00
///The url of the favicon image.
2019-11-02 03:16:47 +00:00
String url ;
2019-11-09 22:35:18 +00:00
///The relationship between the current web page and the favicon image.
2019-11-02 03:16:47 +00:00
String rel ;
2019-11-09 22:35:18 +00:00
///The width of the favicon image.
2019-11-02 03:16:47 +00:00
int width ;
2019-11-09 22:35:18 +00:00
///The height of the favicon image.
2019-11-02 03:16:47 +00:00
int height ;
Favicon ( { @ required this . url , this . rel , this . width , this . height } ) : assert ( url ! = null ) ;
String toString ( ) {
return " url: $ url , rel: $ rel , width: $ width , height: $ height " ;
}
}
2019-11-09 22:35:18 +00:00
///AndroidInAppWebViewCacheMode class represents an Android-specific class used to override the way the cache is used.
2019-10-31 02:20:07 +00:00
class AndroidInAppWebViewCacheMode {
final int _value ;
const AndroidInAppWebViewCacheMode . _internal ( this . _value ) ;
2019-11-04 00:39:23 +00:00
static AndroidInAppWebViewCacheMode fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 3 )
return AndroidInAppWebViewCacheMode . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Default cache usage mode. If the navigation type doesn't impose any specific behavior,
///use cached resources when they are available and not expired, otherwise load resources from the network.
2019-10-31 02:20:07 +00:00
static const LOAD_DEFAULT = const AndroidInAppWebViewCacheMode . _internal ( - 1 ) ;
2019-11-09 22:35:18 +00:00
///Use cached resources when they are available, even if they have expired. Otherwise load resources from the network.
2019-10-31 02:20:07 +00:00
static const LOAD_CACHE_ELSE_NETWORK = const AndroidInAppWebViewCacheMode . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Don't use the cache, load from the network.
2019-10-31 02:20:07 +00:00
static const LOAD_NO_CACHE = const AndroidInAppWebViewCacheMode . _internal ( 2 ) ;
2019-11-09 22:35:18 +00:00
///Don't use the network, load from the cache.
2019-10-31 02:20:07 +00:00
static const LOAD_CACHE_ONLY = const AndroidInAppWebViewCacheMode . _internal ( 3 ) ;
}
2019-11-09 22:35:18 +00:00
///AndroidInAppWebViewModeMenuItem class represents an Android-specific class used to disable the action mode menu items.
2019-10-31 02:20:07 +00:00
///
2019-11-09 22:35:18 +00:00
///**NOTE**: available on Android 24+.
2019-10-31 02:20:07 +00:00
class AndroidInAppWebViewModeMenuItem {
final int _value ;
const AndroidInAppWebViewModeMenuItem . _internal ( this . _value ) ;
2019-11-04 00:39:23 +00:00
static AndroidInAppWebViewModeMenuItem fromValue ( int value ) {
2019-11-09 22:35:18 +00:00
if ( value ! = null & & value ! = 3 & & value > = 0 & & value < = 4 )
2019-11-04 00:39:23 +00:00
return AndroidInAppWebViewModeMenuItem . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///No menu items should be disabled.
2019-10-31 02:20:07 +00:00
static const MENU_ITEM_NONE = const AndroidInAppWebViewModeMenuItem . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Disable menu item "Share".
2019-10-31 02:20:07 +00:00
static const MENU_ITEM_SHARE = const AndroidInAppWebViewModeMenuItem . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Disable menu item "Web Search".
2019-10-31 02:20:07 +00:00
static const MENU_ITEM_WEB_SEARCH = const AndroidInAppWebViewModeMenuItem . _internal ( 2 ) ;
2019-11-09 22:35:18 +00:00
///Disable all the action mode menu items for text processing.
2019-10-31 02:20:07 +00:00
static const MENU_ITEM_PROCESS_TEXT = const AndroidInAppWebViewModeMenuItem . _internal ( 4 ) ;
}
2019-11-09 22:35:18 +00:00
///AndroidInAppWebViewForceDark class represents an Android-specific class used to indicate the force dark mode.
2019-10-31 02:20:07 +00:00
///
2019-11-09 22:35:18 +00:00
///**NOTE**: available on Android 29+.
2019-10-31 02:20:07 +00:00
class AndroidInAppWebViewForceDark {
final int _value ;
const AndroidInAppWebViewForceDark . _internal ( this . _value ) ;
2019-11-04 00:39:23 +00:00
static AndroidInAppWebViewForceDark fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 2 )
return AndroidInAppWebViewForceDark . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Disable force dark, irrespective of the force dark mode of the WebView parent.
///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened.
2019-10-31 02:20:07 +00:00
static const FORCE_DARK_OFF = const AndroidInAppWebViewForceDark . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Enable force dark dependent on the state of the WebView parent view.
2019-10-31 02:20:07 +00:00
static const FORCE_DARK_AUTO = const AndroidInAppWebViewForceDark . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme.
2019-10-31 02:20:07 +00:00
static const FORCE_DARK_ON = const AndroidInAppWebViewForceDark . _internal ( 2 ) ;
}
2019-11-09 22:35:18 +00:00
///AndroidInAppWebViewLayoutAlgorithm class represents an Android-specific class used to set the underlying layout algorithm.
2019-10-31 02:20:07 +00:00
class AndroidInAppWebViewLayoutAlgorithm {
final String _value ;
const AndroidInAppWebViewLayoutAlgorithm . _internal ( this . _value ) ;
2019-11-04 00:39:23 +00:00
static AndroidInAppWebViewLayoutAlgorithm fromValue ( String value ) {
return ( [ " NORMAL " , " TEXT_AUTOSIZING " ] . contains ( value ) ) ? AndroidInAppWebViewLayoutAlgorithm . _internal ( value ) : null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions.
2019-10-31 02:20:07 +00:00
static const NORMAL = const AndroidInAppWebViewLayoutAlgorithm . _internal ( " NORMAL " ) ;
2019-11-09 22:35:18 +00:00
///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode.
///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode.
///
///**NOTE**: available on Android 19+.
2019-10-31 02:20:07 +00:00
static const TEXT_AUTOSIZING = const AndroidInAppWebViewLayoutAlgorithm . _internal ( " TEXT_AUTOSIZING " ) ;
}
2019-11-09 22:35:18 +00:00
///AndroidInAppWebViewMixedContentMode class represents an Android-specific class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin.
2019-10-31 02:20:07 +00:00
///
2019-11-09 22:35:18 +00:00
///**NOTE**: available on Android 21+.
2019-10-31 02:20:07 +00:00
class AndroidInAppWebViewMixedContentMode {
final int _value ;
const AndroidInAppWebViewMixedContentMode . _internal ( this . _value ) ;
2019-11-04 00:39:23 +00:00
static AndroidInAppWebViewMixedContentMode fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 2 )
return AndroidInAppWebViewMixedContentMode . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode.
2019-10-31 02:20:07 +00:00
static const MIXED_CONTENT_ALWAYS_ALLOW = const AndroidInAppWebViewMixedContentMode . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///In this mode, the WebView will not allow a secure origin to load content from an insecure origin.
///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode.
2019-10-31 02:20:07 +00:00
static const MIXED_CONTENT_NEVER_ALLOW = const AndroidInAppWebViewMixedContentMode . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked.
///The types of content are allowed or blocked may change release to release and are not explicitly defined.
///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment.
///For highest security, apps are recommended to use [AndroidInAppWebViewMixedContentMode.MIXED_CONTENT_NEVER_ALLOW].
2019-10-31 02:20:07 +00:00
static const MIXED_CONTENT_COMPATIBILITY_MODE = const AndroidInAppWebViewMixedContentMode . _internal ( 2 ) ;
}
2019-11-09 22:35:18 +00:00
///IosInAppWebViewSelectionGranularity class represents an iOS-specific class used to set the level of granularity with which the user can interactively select content in the web view.
2019-11-04 00:39:23 +00:00
class IosInAppWebViewSelectionGranularity {
2019-10-31 02:20:07 +00:00
final int _value ;
2019-11-04 00:39:23 +00:00
const IosInAppWebViewSelectionGranularity . _internal ( this . _value ) ;
static IosInAppWebViewSelectionGranularity fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 1 )
return IosInAppWebViewSelectionGranularity . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Selection granularity varies automatically based on the selection.
static const DYNAMIC = const IosInAppWebViewSelectionGranularity . _internal ( 0 ) ;
///Selection endpoints can be placed at any character boundary.
static const CHARACTER = const IosInAppWebViewSelectionGranularity . _internal ( 1 ) ;
2019-10-31 02:20:07 +00:00
}
2019-11-09 22:35:18 +00:00
///IosInAppWebViewDataDetectorTypes class represents an iOS-specific class used to specify a dataDetectoryTypes value that adds interactivity to web content that matches the value.
2019-10-31 02:20:07 +00:00
///
2019-11-09 22:35:18 +00:00
///**NOTE**: available on iOS 10.0+.
2019-11-04 00:39:23 +00:00
class IosInAppWebViewDataDetectorTypes {
2019-10-31 02:20:07 +00:00
final String _value ;
2019-11-04 00:39:23 +00:00
const IosInAppWebViewDataDetectorTypes . _internal ( this . _value ) ;
static IosInAppWebViewDataDetectorTypes fromValue ( String value ) {
return ( [ " NONE " , " PHONE_NUMBER " , " LINK " , " ADDRESS " , " CALENDAR_EVENT " , " TRACKING_NUMBER " ,
" TRACKING_NUMBER " , " FLIGHT_NUMBER " , " LOOKUP_SUGGESTION " , " SPOTLIGHT_SUGGESTION " , " ALL " ] . contains ( value ) ) ? IosInAppWebViewDataDetectorTypes . _internal ( value ) : null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///No detection is performed.
2019-11-04 00:39:23 +00:00
static const NONE = const IosInAppWebViewDataDetectorTypes . _internal ( " NONE " ) ;
2019-11-09 22:35:18 +00:00
///Phone numbers are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const PHONE_NUMBER = const IosInAppWebViewDataDetectorTypes . _internal ( " PHONE_NUMBER " ) ;
2019-11-09 22:35:18 +00:00
///URLs in text are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const LINK = const IosInAppWebViewDataDetectorTypes . _internal ( " LINK " ) ;
2019-11-09 22:35:18 +00:00
///Addresses are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const ADDRESS = const IosInAppWebViewDataDetectorTypes . _internal ( " ADDRESS " ) ;
2019-11-09 22:35:18 +00:00
///Dates and times that are in the future are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const CALENDAR_EVENT = const IosInAppWebViewDataDetectorTypes . _internal ( " CALENDAR_EVENT " ) ;
2019-11-09 22:35:18 +00:00
///Tracking numbers are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const TRACKING_NUMBER = const IosInAppWebViewDataDetectorTypes . _internal ( " TRACKING_NUMBER " ) ;
2019-11-09 22:35:18 +00:00
///Flight numbers are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const FLIGHT_NUMBER = const IosInAppWebViewDataDetectorTypes . _internal ( " FLIGHT_NUMBER " ) ;
2019-11-09 22:35:18 +00:00
///Lookup suggestions are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const LOOKUP_SUGGESTION = const IosInAppWebViewDataDetectorTypes . _internal ( " LOOKUP_SUGGESTION " ) ;
2019-11-09 22:35:18 +00:00
///Spotlight suggestions are detected and turned into links.
2019-11-04 00:39:23 +00:00
static const SPOTLIGHT_SUGGESTION = const IosInAppWebViewDataDetectorTypes . _internal ( " SPOTLIGHT_SUGGESTION " ) ;
2019-11-09 22:35:18 +00:00
///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added.
2019-11-04 00:39:23 +00:00
static const ALL = const IosInAppWebViewDataDetectorTypes . _internal ( " ALL " ) ;
2019-10-31 02:20:07 +00:00
}
2019-11-09 22:35:18 +00:00
///InAppWebViewUserPreferredContentMode class represents the content mode to prefer when loading and rendering a webpage.
2019-10-31 22:09:54 +00:00
class InAppWebViewUserPreferredContentMode {
2019-10-31 02:20:07 +00:00
final int _value ;
2019-10-31 22:09:54 +00:00
const InAppWebViewUserPreferredContentMode . _internal ( this . _value ) ;
2019-11-04 00:39:23 +00:00
static InAppWebViewUserPreferredContentMode fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 2 )
return InAppWebViewUserPreferredContentMode . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///The recommended content mode for the current platform.
2019-10-31 22:09:54 +00:00
static const RECOMMENDED = const InAppWebViewUserPreferredContentMode . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Represents content targeting mobile browsers.
2019-10-31 22:09:54 +00:00
static const MOBILE = const InAppWebViewUserPreferredContentMode . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Represents content targeting desktop browsers.
2019-10-31 22:09:54 +00:00
static const DESKTOP = const InAppWebViewUserPreferredContentMode . _internal ( 2 ) ;
2019-10-31 02:20:07 +00:00
}
2019-11-09 22:35:18 +00:00
///IosWebViewOptionsPresentationStyle class represents an iOS-specific class used to specify the modal presentation style when presenting a view controller.
2019-11-04 00:39:23 +00:00
class IosWebViewOptionsPresentationStyle {
2019-10-31 02:20:07 +00:00
final int _value ;
2019-11-04 00:39:23 +00:00
const IosWebViewOptionsPresentationStyle . _internal ( this . _value ) ;
static IosWebViewOptionsPresentationStyle fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 9 )
return IosWebViewOptionsPresentationStyle . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///A presentation style in which the presented view covers the screen.
2019-11-04 00:39:23 +00:00
static const FULL_SCREEN = const IosWebViewOptionsPresentationStyle . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///A presentation style that partially covers the underlying content.
2019-11-04 00:39:23 +00:00
static const PAGE_SHEET = const IosWebViewOptionsPresentationStyle . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///A presentation style that displays the content centered in the screen.
2019-11-04 00:39:23 +00:00
static const FORM_SHEET = const IosWebViewOptionsPresentationStyle . _internal ( 2 ) ;
2019-11-09 22:35:18 +00:00
///A presentation style where the content is displayed over another view controller’ s content.
2019-11-04 00:39:23 +00:00
static const CURRENT_CONTEXT = const IosWebViewOptionsPresentationStyle . _internal ( 3 ) ;
2019-11-09 22:35:18 +00:00
///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects.
2019-11-04 00:39:23 +00:00
static const CUSTOM = const IosWebViewOptionsPresentationStyle . _internal ( 4 ) ;
2019-11-09 22:35:18 +00:00
///A view presentation style in which the presented view covers the screen.
2019-11-04 00:39:23 +00:00
static const OVER_FULL_SCREEN = const IosWebViewOptionsPresentationStyle . _internal ( 5 ) ;
2019-11-09 22:35:18 +00:00
///A presentation style where the content is displayed over another view controller’ s content.
2019-11-04 00:39:23 +00:00
static const OVER_CURRENT_CONTEXT = const IosWebViewOptionsPresentationStyle . _internal ( 6 ) ;
2019-11-09 22:35:18 +00:00
///A presentation style where the content is displayed in a popover view.
2019-11-04 00:39:23 +00:00
static const POPOVER = const IosWebViewOptionsPresentationStyle . _internal ( 7 ) ;
2019-11-09 22:35:18 +00:00
///A presentation style that indicates no adaptations should be made.
2019-11-04 00:39:23 +00:00
static const NONE = const IosWebViewOptionsPresentationStyle . _internal ( 8 ) ;
2019-11-09 22:35:18 +00:00
///The default presentation style chosen by the system.
///
///**NOTE**: available on iOS 13.0+.
2019-11-04 00:39:23 +00:00
static const AUTOMATIC = const IosWebViewOptionsPresentationStyle . _internal ( 9 ) ;
2019-10-31 02:20:07 +00:00
}
2019-11-09 22:35:18 +00:00
///IosWebViewOptionsTransitionStyle class represents an iOS-specific class used to specify the transition style when presenting a view controller.
2019-11-04 00:39:23 +00:00
class IosWebViewOptionsTransitionStyle {
2019-10-31 02:20:07 +00:00
final int _value ;
2019-11-04 00:39:23 +00:00
const IosWebViewOptionsTransitionStyle . _internal ( this . _value ) ;
static IosWebViewOptionsTransitionStyle fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 3 )
return IosWebViewOptionsTransitionStyle . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///When the view controller is presented, its view slides up from the bottom of the screen.
///On dismissal, the view slides back down. This is the default transition style.
2019-11-04 00:39:23 +00:00
static const COVER_VERTICAL = const IosWebViewOptionsTransitionStyle . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left,
///resulting in the revealing of the new view as if it were on the back of the previous view.
///On dismissal, the flip occurs from left-to-right, returning to the original view.
2019-11-04 00:39:23 +00:00
static const FLIP_HORIZONTAL = const IosWebViewOptionsTransitionStyle . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///When the view controller is presented, the current view fades out while the new view fades in at the same time.
///On dismissal, a similar type of cross-fade is used to return to the original view.
2019-11-04 00:39:23 +00:00
static const CROSS_DISSOLVE = const IosWebViewOptionsTransitionStyle . _internal ( 2 ) ;
2019-11-09 22:35:18 +00:00
///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath.
///On dismissal, the curled up page unfurls itself back on top of the presented view.
///A view controller presented using this transition is itself prevented from presenting any additional view controllers.
2019-11-04 00:39:23 +00:00
static const PARTIAL_CURL = const IosWebViewOptionsTransitionStyle . _internal ( 3 ) ;
2019-10-31 02:20:07 +00:00
}
2019-11-09 22:35:18 +00:00
///IosWebViewOptionsTransitionStyle class represents an iOS-specific class used to set the custom style for the dismiss button.
2019-10-31 02:20:07 +00:00
///
2019-11-09 22:35:18 +00:00
///**NOTE**: available on iOS 11.0+.
2019-11-04 00:39:23 +00:00
class IosSafariOptionsDismissButtonStyle {
2019-10-31 02:20:07 +00:00
final int _value ;
2019-11-04 00:39:23 +00:00
const IosSafariOptionsDismissButtonStyle . _internal ( this . _value ) ;
static IosSafariOptionsDismissButtonStyle fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 2 )
return IosSafariOptionsDismissButtonStyle . _internal ( value ) ;
return null ;
}
2019-10-31 02:20:07 +00:00
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Makes the button title the localized string "Done".
2019-11-04 00:39:23 +00:00
static const DONE = const IosSafariOptionsDismissButtonStyle . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Makes the button title the localized string "Close".
2019-11-04 00:39:23 +00:00
static const CLOSE = const IosSafariOptionsDismissButtonStyle . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///Makes the button title the localized string "Cancel".
2019-11-04 00:39:23 +00:00
static const CANCEL = const IosSafariOptionsDismissButtonStyle . _internal ( 2 ) ;
}
2019-11-09 22:35:18 +00:00
///InAppWebViewWidgetOptions class represents the options that can be used for an [InAppWebView].
2019-11-04 00:39:23 +00:00
class InAppWebViewWidgetOptions {
2019-11-09 22:35:18 +00:00
///Cross-platform options.
2019-11-04 00:39:23 +00:00
InAppWebViewOptions inAppWebViewOptions ;
2019-11-09 22:35:18 +00:00
///Android-specific options.
2019-11-04 00:39:23 +00:00
AndroidInAppWebViewOptions androidInAppWebViewOptions ;
2019-11-09 22:35:18 +00:00
///iOS-specific options.
2019-11-04 00:39:23 +00:00
IosInAppWebViewOptions iosInAppWebViewOptions ;
InAppWebViewWidgetOptions ( { this . inAppWebViewOptions , this . androidInAppWebViewOptions , this . iosInAppWebViewOptions } ) ;
}
2019-11-09 22:35:18 +00:00
///InAppBrowserClassOptions class represents the options that can be used for an [InAppBrowser] WebView.
2019-11-04 00:39:23 +00:00
class InAppBrowserClassOptions {
2019-11-09 22:35:18 +00:00
///Cross-platform options.
2019-11-04 00:39:23 +00:00
InAppBrowserOptions inAppBrowserOptions ;
2019-11-09 22:35:18 +00:00
///Android-specific options.
2019-11-04 00:39:23 +00:00
AndroidInAppBrowserOptions androidInAppBrowserOptions ;
2019-11-09 22:35:18 +00:00
///iOS-specific options.
2019-11-04 00:39:23 +00:00
IosInAppBrowserOptions iosInAppBrowserOptions ;
2019-11-09 22:35:18 +00:00
///WebView options.
2019-11-04 00:39:23 +00:00
InAppWebViewWidgetOptions inAppWebViewWidgetOptions ;
InAppBrowserClassOptions ( { this . inAppBrowserOptions , this . androidInAppBrowserOptions , this . iosInAppBrowserOptions , this . inAppWebViewWidgetOptions } ) ;
2019-10-31 02:20:07 +00:00
}
2019-11-04 00:39:23 +00:00
2019-11-09 22:35:18 +00:00
///ChromeSafariBrowserClassOptions class represents the options that can be used for an [ChromeSafariBrowser] window.
2019-11-04 00:39:23 +00:00
class ChromeSafariBrowserClassOptions {
2019-11-09 22:35:18 +00:00
///Android-specific options.
2019-11-04 00:39:23 +00:00
AndroidChromeCustomTabsOptions androidChromeCustomTabsOptions ;
2019-11-09 22:35:18 +00:00
///iOS-specific options.
2019-11-04 00:39:23 +00:00
IosSafariOptions iosSafariOptions ;
ChromeSafariBrowserClassOptions ( { this . androidChromeCustomTabsOptions , this . iosSafariOptions } ) ;
2019-11-05 02:44:22 +00:00
}
2019-11-09 22:35:18 +00:00
///AjaxRequestAction class used by [AjaxRequest] class.
2019-11-05 02:44:22 +00:00
class AjaxRequestAction {
final int _value ;
const AjaxRequestAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Aborts the current [AjaxRequest].
2019-11-05 02:44:22 +00:00
static const ABORT = const AjaxRequestAction . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Proceeds with the current [AjaxRequest].
2019-11-05 02:44:22 +00:00
static const PROCEED = const AjaxRequestAction . _internal ( 1 ) ;
2019-11-05 23:23:24 +00:00
Map < String , dynamic > toMap ( ) {
return {
" action " : _value ,
} ;
}
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
2019-11-05 02:44:22 +00:00
}
2019-11-09 22:35:18 +00:00
///AjaxRequestEventType class used by [AjaxRequestEvent] class.
2019-11-05 02:44:22 +00:00
class AjaxRequestEventType {
final String _value ;
const AjaxRequestEventType . _internal ( this . _value ) ;
static AjaxRequestEventType fromValue ( String value ) {
return ( [ " loadstart " , " load " , " loadend " , " progress " , " error " , " abort " ] . contains ( value ) ) ? AjaxRequestEventType . _internal ( value ) : null ;
}
toValue ( ) = > _value ;
String toString ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///The LOADSTART event is fired when a request has started to load data.
2019-11-05 02:44:22 +00:00
static const LOADSTART = const AjaxRequestEventType . _internal ( " loadstart " ) ;
2019-11-09 22:35:18 +00:00
///The LOAD event is fired when an `XMLHttpRequest` transaction completes successfully.
2019-11-05 02:44:22 +00:00
static const LOAD = const AjaxRequestEventType . _internal ( " load " ) ;
2019-11-09 22:35:18 +00:00
///The LOADEND event is fired when a request has completed, whether successfully (after [AjaxRequestEventType.LOAD]) or
///unsuccessfully (after [AjaxRequestEventType.ABORT] or [AjaxRequestEventType.ERROR]).
2019-11-05 02:44:22 +00:00
static const LOADEND = const AjaxRequestEventType . _internal ( " loadend " ) ;
2019-11-09 22:35:18 +00:00
///The PROGRESS event is fired periodically when a request receives more data.
2019-11-05 02:44:22 +00:00
static const PROGRESS = const AjaxRequestEventType . _internal ( " progress " ) ;
2019-11-09 22:35:18 +00:00
///The ERROR event is fired when the request encountered an error.
2019-11-05 02:44:22 +00:00
static const ERROR = const AjaxRequestEventType . _internal ( " error " ) ;
2019-11-09 22:35:18 +00:00
///The ABORT event is fired when a request has been aborted.
2019-11-05 02:44:22 +00:00
static const ABORT = const AjaxRequestEventType . _internal ( " abort " ) ;
2019-11-09 22:35:18 +00:00
///The TIMEOUT event is fired when progression is terminated due to preset time expiring.
static const TIMEOUT = const AjaxRequestEventType . _internal ( " timeout " ) ;
2019-11-05 02:44:22 +00:00
}
2019-11-09 22:35:18 +00:00
///AjaxRequestEvent class used by [AjaxRequest] class. It represents events measuring progress of an [AjaxRequest].
2019-11-05 02:44:22 +00:00
class AjaxRequestEvent {
2019-11-09 22:35:18 +00:00
///Event type.
2019-11-05 02:44:22 +00:00
AjaxRequestEventType type ;
2019-11-09 22:35:18 +00:00
///Is a Boolean flag indicating if the total work to be done, and the amount of work already done, by the underlying process is calculable.
///In other words, it tells if the progress is measurable or not.
2019-11-05 02:44:22 +00:00
bool lengthComputable ;
2019-11-09 22:35:18 +00:00
///Is an integer representing the amount of work already performed by the underlying process.
///The ratio of work done can be calculated with the property and [AjaxRequestEvent.total].
///When downloading a resource using HTTP, this only represent the part of the content itself, not headers and other overhead.
int loaded ;
///Is an integer representing the total amount of work that the underlying process is in the progress of performing.
///When downloading a resource using HTTP, this only represent the content itself, not headers and other overhead.
int total ;
2019-11-05 02:44:22 +00:00
2019-11-09 22:35:18 +00:00
AjaxRequestEvent ( { this . type , this . lengthComputable , this . loaded , this . total } ) ;
2019-11-05 02:44:22 +00:00
}
2019-11-09 22:35:18 +00:00
///AjaxRequestReadyState class used by [AjaxRequest] class. It represents the state of an [AjaxRequest].
2019-11-05 02:44:22 +00:00
class AjaxRequestReadyState {
final int _value ;
const AjaxRequestReadyState . _internal ( this . _value ) ;
static AjaxRequestReadyState fromValue ( int value ) {
if ( value ! = null & & value > = 0 & & value < = 4 )
return AjaxRequestReadyState . _internal ( value ) ;
return null ;
}
toValue ( ) = > _value ;
String toString ( ) = > _value . toString ( ) ;
2019-11-09 22:35:18 +00:00
///Client has been created. `XMLHttpRequest.open()` not called yet.
2019-11-05 02:44:22 +00:00
static const UNSENT = const AjaxRequestReadyState . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///`XMLHttpRequest.open()` has been called.
2019-11-05 02:44:22 +00:00
static const OPENED = const AjaxRequestReadyState . _internal ( 1 ) ;
2019-11-09 22:35:18 +00:00
///`XMLHttpRequest.send()` has been called, and [AjaxRequest.headers] and [AjaxRequest.status] are available.
2019-11-05 02:44:22 +00:00
static const HEADERS_RECEIVED = const AjaxRequestReadyState . _internal ( 2 ) ;
2019-11-09 22:35:18 +00:00
///Downloading; [AjaxRequest.responseText] holds partial data.
2019-11-05 02:44:22 +00:00
static const LOADING = const AjaxRequestReadyState . _internal ( 3 ) ;
2019-11-09 22:35:18 +00:00
///The operation is complete.
2019-11-05 02:44:22 +00:00
static const DONE = const AjaxRequestReadyState . _internal ( 4 ) ;
}
2019-11-09 22:35:18 +00:00
///AjaxRequest class represents a JavaScript [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) object.
2019-11-05 02:44:22 +00:00
class AjaxRequest {
2019-11-09 22:35:18 +00:00
///Data passed to as a parameter to the `XMLHttpRequest.send()` method.
2019-11-05 02:44:22 +00:00
dynamic data ;
2019-11-09 22:35:18 +00:00
///The HTTP request method of the `XMLHttpRequest` request.
2019-11-05 02:44:22 +00:00
String method ;
2019-11-09 22:35:18 +00:00
///The URL of the `XMLHttpRequest` request.
2019-11-05 02:44:22 +00:00
String url ;
2019-11-09 22:35:18 +00:00
///An optional Boolean parameter, defaulting to true, indicating whether or not the request is performed asynchronously.
2019-11-05 02:44:22 +00:00
bool isAsync ;
2019-11-09 22:35:18 +00:00
///The optional user name to use for authentication purposes; by default, this is the null value.
2019-11-05 02:44:22 +00:00
String user ;
2019-11-09 22:35:18 +00:00
///The optional password to use for authentication purposes; by default, this is the null value.
2019-11-05 02:44:22 +00:00
String password ;
2019-11-09 22:35:18 +00:00
///The XMLHttpRequest.withCredentials property is a Boolean that indicates whether or not cross-site Access-Control requests
///should be made using credentials such as cookies, authorization headers or TLS client certificates.
///Setting withCredentials has no effect on same-site requests.
///In addition, this flag is also used to indicate when cookies are to be ignored in the response. The default is false.
2019-11-05 02:44:22 +00:00
bool withCredentials ;
2019-11-09 22:35:18 +00:00
///The HTTP request headers.
2019-11-05 02:44:22 +00:00
Map < dynamic , dynamic > headers ;
2019-11-09 22:35:18 +00:00
///The state of the `XMLHttpRequest` request.
2019-11-05 02:44:22 +00:00
AjaxRequestReadyState readyState ;
2019-11-09 22:35:18 +00:00
///The numerical HTTP [status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) of the `XMLHttpRequest`'s response.
2019-11-05 02:44:22 +00:00
int status ;
2019-11-09 22:35:18 +00:00
///The serialized URL of the response or the empty string if the URL is null.
///If the URL is returned, any URL fragment present in the URL will be stripped away.
///The value of responseURL will be the final URL obtained after any redirects.
2019-11-05 02:44:22 +00:00
String responseURL ;
2019-11-09 22:35:18 +00:00
///It is an enumerated string value specifying the type of data contained in the response.
///It also lets the author change the [response type](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType).
///If an empty string is set as the value of responseType, the default value of text is used.
2019-11-05 02:44:22 +00:00
String responseType ;
2019-11-09 22:35:18 +00:00
///The text received from a server following a request being sent.
2019-11-05 02:44:22 +00:00
String responseText ;
2019-11-09 22:35:18 +00:00
///A String containing the response's status message as returned by the HTTP server.
///Unlike [AjaxRequest.status] which indicates a numerical status code, this property contains the text of the response status, such as "OK" or "Not Found".
///If the request's readyState is in [AjaxRequestReadyState.UNSENT] or [AjaxRequestReadyState.OPENED] state, the value of statusText will be an empty string.
///If the server response doesn't explicitly specify a status text, statusText will assume the default value "OK".
2019-11-05 02:44:22 +00:00
String statusText ;
2019-11-09 22:35:18 +00:00
///All the response headers or returns null if no response has been received. If a network error happened, an empty string is returned.
2019-11-05 02:44:22 +00:00
Map < dynamic , dynamic > responseHeaders ;
2019-11-09 22:35:18 +00:00
///Event type of the `XMLHttpRequest` request.
2019-11-05 02:44:22 +00:00
AjaxRequestEvent event ;
2019-11-09 22:35:18 +00:00
///Indicates the [AjaxRequestAction] that can be used to control the `XMLHttpRequest` request.
2019-11-05 02:44:22 +00:00
AjaxRequestAction action ;
AjaxRequest ( { this . data , this . method , this . url , this . isAsync , this . user , this . password ,
this . withCredentials , this . headers , this . readyState , this . status , this . responseURL , this . responseType ,
this . responseText , this . statusText , this . responseHeaders , this . event , this . action = AjaxRequestAction . PROCEED } ) ;
Map < String , dynamic > toMap ( ) {
return {
" data " : data ,
" method " : method ,
" url " : url ,
" isAsync " : isAsync ,
" user " : user ,
" password " : password ,
" withCredentials " : withCredentials ,
" headers " : headers ,
" readyState " : readyState ? . toValue ( ) ,
" status " : status ,
" responseURL " : responseURL ,
" responseType " : responseType ,
" responseText " : responseText ,
" statusText " : statusText ,
" responseHeaders " : responseHeaders ,
" action " : action ? . toValue ( )
} ;
}
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
}
2019-11-09 22:35:18 +00:00
///FetchRequestAction class used by [FetchRequest] class.
2019-11-05 02:44:22 +00:00
class FetchRequestAction {
final int _value ;
const FetchRequestAction . _internal ( this . _value ) ;
toValue ( ) = > _value ;
2019-11-09 22:35:18 +00:00
///Aborts the fetch request.
2019-11-05 02:44:22 +00:00
static const ABORT = const FetchRequestAction . _internal ( 0 ) ;
2019-11-09 22:35:18 +00:00
///Proceeds with the fetch request.
2019-11-05 02:44:22 +00:00
static const PROCEED = const FetchRequestAction . _internal ( 1 ) ;
}
2019-11-09 22:35:18 +00:00
///FetchRequestCredential class is an interface for [FetchRequestCredentialDefault], [FetchRequestFederatedCredential] and [FetchRequestPasswordCredential] classes.
2019-11-06 21:55:54 +00:00
class FetchRequestCredential {
2019-11-09 22:35:18 +00:00
///Type of credentials.
2019-11-06 21:55:54 +00:00
String type ;
FetchRequestCredential ( { this . type } ) ;
Map < String , dynamic > toMap ( ) {
return {
" type " : type
} ;
}
}
2019-11-09 22:35:18 +00:00
///FetchRequestCredentialDefault class represents the default credentials used by an [FetchRequest].
2019-11-06 21:55:54 +00:00
class FetchRequestCredentialDefault extends FetchRequestCredential {
2019-11-09 22:35:18 +00:00
///The value of the credentials.
2019-11-06 21:55:54 +00:00
String value ;
FetchRequestCredentialDefault ( { type , this . value } ) : super ( type: type ) ;
Map < String , dynamic > toMap ( ) {
return {
" type " : type ,
" value " : value ,
} ;
}
}
2019-11-09 22:35:18 +00:00
///FetchRequestFederatedCredential class represents a [FederatedCredential](https://developer.mozilla.org/en-US/docs/Web/API/FederatedCredential) type of credentials.
2019-11-06 21:55:54 +00:00
class FetchRequestFederatedCredential extends FetchRequestCredential {
2019-11-09 22:35:18 +00:00
///Credential's identifier.
2019-11-06 21:55:54 +00:00
dynamic id ;
2019-11-09 22:35:18 +00:00
///The name associated with a credential. It should be a human-readable, public name.
2019-11-06 21:55:54 +00:00
String name ;
2019-11-09 22:35:18 +00:00
///Credential's federated identity protocol.
2019-11-06 21:55:54 +00:00
String protocol ;
2019-11-09 22:35:18 +00:00
///Credential's federated identity provider.
2019-11-06 21:55:54 +00:00
String provider ;
2019-11-09 22:35:18 +00:00
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
2019-11-06 21:55:54 +00:00
String iconURL ;
FetchRequestFederatedCredential ( { type , this . id , this . name , this . protocol , this . provider , this . iconURL } ) : super ( type: type ) ;
Map < String , dynamic > toMap ( ) {
return {
" type " : type ,
" id " : id ,
" name " : name ,
" protocol " : protocol ,
" provider " : provider ,
" iconURL " : iconURL
} ;
}
}
2019-11-09 22:35:18 +00:00
///FetchRequestPasswordCredential class represents a [PasswordCredential](https://developer.mozilla.org/en-US/docs/Web/API/PasswordCredential) type of credentials.
2019-11-06 21:55:54 +00:00
class FetchRequestPasswordCredential extends FetchRequestCredential {
2019-11-09 22:35:18 +00:00
///Credential's identifier.
2019-11-06 21:55:54 +00:00
dynamic id ;
2019-11-09 22:35:18 +00:00
///The name associated with a credential. It should be a human-readable, public name.
2019-11-06 21:55:54 +00:00
String name ;
2019-11-09 22:35:18 +00:00
///The password of the credential.
2019-11-06 21:55:54 +00:00
String password ;
2019-11-09 22:35:18 +00:00
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
2019-11-06 21:55:54 +00:00
String iconURL ;
FetchRequestPasswordCredential ( { type , this . id , this . name , this . password , this . iconURL } ) : super ( type: type ) ;
Map < String , dynamic > toMap ( ) {
return {
" type " : type ,
" id " : id ,
" name " : name ,
" password " : password ,
" iconURL " : iconURL
} ;
}
}
2019-11-09 22:35:18 +00:00
///FetchRequest class represents a HTTP request created with JavaScript using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).
2019-11-05 02:44:22 +00:00
class FetchRequest {
2019-11-09 22:35:18 +00:00
///The URL of the request.
2019-11-05 02:44:22 +00:00
String url ;
2019-11-09 22:35:18 +00:00
///The HTTP request method used of the request.
2019-11-05 02:44:22 +00:00
String method ;
2019-11-09 22:35:18 +00:00
///The HTTP request headers.
2019-11-06 21:55:54 +00:00
Map < String , dynamic > headers ;
2019-11-09 22:35:18 +00:00
///Body of the request.
2019-11-06 21:55:54 +00:00
Uint8List body ;
2019-11-09 22:35:18 +00:00
///The mode used by the request.
2019-11-05 02:44:22 +00:00
String mode ;
2019-11-09 22:35:18 +00:00
///The request credentials used by the request.
2019-11-06 21:55:54 +00:00
FetchRequestCredential credentials ;
2019-11-09 22:35:18 +00:00
///The cache mode used by the request.
2019-11-05 02:44:22 +00:00
String cache ;
2019-11-09 22:35:18 +00:00
///The redirect mode used by the request.
2019-11-05 02:44:22 +00:00
String redirect ;
2019-11-09 22:35:18 +00:00
///A String specifying no-referrer, client, or a URL.
2019-11-05 02:44:22 +00:00
String referrer ;
2019-11-09 22:35:18 +00:00
///The value of the referer HTTP header.
2019-11-05 02:44:22 +00:00
String referrerPolicy ;
2019-11-09 22:35:18 +00:00
///Contains the subresource integrity value of the request.
2019-11-05 02:44:22 +00:00
String integrity ;
2019-11-09 22:35:18 +00:00
///The keepalive option used to allow the request to outlive the page.
2019-11-05 02:44:22 +00:00
bool keepalive ;
2019-11-09 22:35:18 +00:00
///Indicates the [FetchRequestAction] that can be used to control the request.
2019-11-05 02:44:22 +00:00
FetchRequestAction action ;
FetchRequest ( { this . url , this . method , this . headers , this . body , this . mode , this . credentials ,
this . cache , this . redirect , this . referrer , this . referrerPolicy , this . integrity , this . keepalive ,
this . action = FetchRequestAction . PROCEED } ) ;
Map < String , dynamic > toMap ( ) {
return {
" url " : url ,
" method " : method ,
" headers " : headers ,
" body " : body ,
" mode " : mode ,
2019-11-06 21:55:54 +00:00
" credentials " : credentials ? . toMap ( ) ,
2019-11-05 02:44:22 +00:00
" cache " : cache ,
" redirect " : redirect ,
" referrer " : referrer ,
" referrerPolicy " : referrerPolicy ,
" integrity " : integrity ,
" keepalive " : keepalive ,
" action " : action ? . toValue ( )
} ;
}
Map < String , dynamic > toJson ( ) {
return this . toMap ( ) ;
}
2019-11-06 21:55:54 +00:00
static FetchRequestCredential createFetchRequestCredentialFromMap ( credentialsMap ) {
if ( credentialsMap ! = null ) {
if ( credentialsMap [ " type " ] = = " default " ) {
return FetchRequestCredentialDefault ( type: credentialsMap [ " type " ] , value: credentialsMap [ " value " ] ) ;
} else if ( credentialsMap [ " type " ] = = " federated " ) {
return FetchRequestFederatedCredential ( type: credentialsMap [ " type " ] , id: credentialsMap [ " id " ] , name: credentialsMap [ " name " ] ,
protocol: credentialsMap [ " protocol " ] , provider: credentialsMap [ " provider " ] , iconURL: credentialsMap [ " iconURL " ] ) ;
} else if ( credentialsMap [ " type " ] = = " password " ) {
return FetchRequestPasswordCredential ( type: credentialsMap [ " type " ] , id: credentialsMap [ " id " ] , name: credentialsMap [ " name " ] ,
password: credentialsMap [ " password " ] , iconURL: credentialsMap [ " iconURL " ] ) ;
}
}
return null ;
}
2019-11-04 00:39:23 +00:00
}