flutter format

This commit is contained in:
Lorenzo Pichilli 2020-06-29 16:37:36 +02:00
parent eea691664b
commit 0c71edf8a6
6 changed files with 116 additions and 138 deletions

View File

@ -171,7 +171,7 @@ class HeadlessInAppWebView implements WebView {
@override
final void Function(InAppWebViewController controller, String title)
onTitleChanged;
onTitleChanged;
@override
final void Function(InAppWebViewController controller)
@ -201,20 +201,16 @@ class HeadlessInAppWebView implements WebView {
CreateWindowRequest onCreateWindowRequest) onCreateWindow;
@override
final void Function(InAppWebViewController controller)
onCloseWindow;
final void Function(InAppWebViewController controller) onCloseWindow;
@override
final void Function(InAppWebViewController controller)
onWindowFocus;
final void Function(InAppWebViewController controller) onWindowFocus;
@override
final void Function(InAppWebViewController controller)
onWindowBlur;
final void Function(InAppWebViewController controller) onWindowBlur;
@override
final void Function(InAppWebViewController controller)
androidOnRequestFocus;
final void Function(InAppWebViewController controller) androidOnRequestFocus;
@override
final void Function(InAppWebViewController controller, String url)
@ -226,15 +222,18 @@ class HeadlessInAppWebView implements WebView {
@override
final Future<JsAlertResponse> Function(
InAppWebViewController controller, JsAlertRequest jsAlertRequest) onJsAlert;
InAppWebViewController controller, JsAlertRequest jsAlertRequest)
onJsAlert;
@override
final Future<JsConfirmResponse> Function(
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest) onJsConfirm;
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)
onJsConfirm;
@override
final Future<JsPromptResponse> Function(InAppWebViewController controller,
JsPromptRequest jsPromptRequest) onJsPrompt;
final Future<JsPromptResponse> Function(
InAppWebViewController controller, JsPromptRequest jsPromptRequest)
onJsPrompt;
@override
final void Function(InAppWebViewController controller, String url, int code,
@ -352,18 +351,20 @@ class HeadlessInAppWebView implements WebView {
@override
final void Function(InAppWebViewController controller, Uint8List icon)
androidOnReceivedIcon;
androidOnReceivedIcon;
@override
final void Function(InAppWebViewController controller, String url, bool precomposed)
androidOnReceivedTouchIconUrl;
final void Function(
InAppWebViewController controller, String url, bool precomposed)
androidOnReceivedTouchIconUrl;
@override
final Future<JsBeforeUnloadResponse> Function(
InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)
androidOnJsBeforeUnload;
InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest) androidOnJsBeforeUnload;
@override
final void Function(InAppWebViewController controller, LoginRequest loginRequest)
androidOnReceivedLoginRequest;
final void Function(
InAppWebViewController controller, LoginRequest loginRequest)
androidOnReceivedLoginRequest;
}

View File

@ -567,7 +567,6 @@ class InAppBrowser {
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)
void onTitleChanged(String title) {}
///Event fired when the WebView notifies that a loading URL has been flagged by Safe Browsing.
///The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
///

View File

@ -135,7 +135,7 @@ class InAppWebView extends StatefulWidget implements WebView {
@override
final void Function(InAppWebViewController controller, String title)
onTitleChanged;
onTitleChanged;
@override
final void Function(InAppWebViewController controller)
@ -165,28 +165,25 @@ class InAppWebView extends StatefulWidget implements WebView {
CreateWindowRequest onCreateWindowRequest) onCreateWindow;
@override
final void Function(InAppWebViewController controller)
onCloseWindow;
final void Function(InAppWebViewController controller) onCloseWindow;
@override
final void Function(InAppWebViewController controller)
onWindowFocus;
final void Function(InAppWebViewController controller) onWindowFocus;
@override
final void Function(InAppWebViewController controller)
onWindowBlur;
final void Function(InAppWebViewController controller) onWindowBlur;
@override
final void Function(InAppWebViewController controller)
androidOnRequestFocus;
final void Function(InAppWebViewController controller) androidOnRequestFocus;
@override
final void Function(InAppWebViewController controller, Uint8List icon)
androidOnReceivedIcon;
androidOnReceivedIcon;
@override
final void Function(InAppWebViewController controller, String url, bool precomposed)
androidOnReceivedTouchIconUrl;
final void Function(
InAppWebViewController controller, String url, bool precomposed)
androidOnReceivedTouchIconUrl;
@override
final void Function(InAppWebViewController controller, String url)
@ -198,15 +195,18 @@ class InAppWebView extends StatefulWidget implements WebView {
@override
final Future<JsAlertResponse> Function(
InAppWebViewController controller, JsAlertRequest jsAlertRequest) onJsAlert;
InAppWebViewController controller, JsAlertRequest jsAlertRequest)
onJsAlert;
@override
final Future<JsConfirmResponse> Function(
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest) onJsConfirm;
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)
onJsConfirm;
@override
final Future<JsPromptResponse> Function(InAppWebViewController controller,
JsPromptRequest jsPromptRequest) onJsPrompt;
final Future<JsPromptResponse> Function(
InAppWebViewController controller, JsPromptRequest jsPromptRequest)
onJsPrompt;
@override
final void Function(InAppWebViewController controller, String url, int code,
@ -324,12 +324,13 @@ class InAppWebView extends StatefulWidget implements WebView {
@override
final Future<JsBeforeUnloadResponse> Function(
InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)
androidOnJsBeforeUnload;
InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest) androidOnJsBeforeUnload;
@override
final void Function(InAppWebViewController controller, LoginRequest loginRequest)
androidOnReceivedLoginRequest;
final void Function(
InAppWebViewController controller, LoginRequest loginRequest)
androidOnReceivedLoginRequest;
}
class _InAppWebViewState extends State<InAppWebView> {

View File

@ -228,36 +228,39 @@ class InAppWebViewController {
if (_webview != null && _webview.onCreateWindow != null)
webView = await _webview.onCreateWindow(this, createWindowRequest);
else if (_inAppBrowser != null) {
inAppBrowserWindow = await _inAppBrowser.onCreateWindow(createWindowRequest);
inAppBrowserWindow =
await _inAppBrowser.onCreateWindow(createWindowRequest);
assert(
inAppBrowserWindow is InAppBrowser || inAppBrowserWindow is HeadlessInAppWebView,
"InAppBrowser.onCreateWindow should return an \"InAppBrowser\" instance or a \"HeadlessInAppWebView\" instance."
);
inAppBrowserWindow is InAppBrowser ||
inAppBrowserWindow is HeadlessInAppWebView,
"InAppBrowser.onCreateWindow should return an \"InAppBrowser\" instance or a \"HeadlessInAppWebView\" instance.");
}
int webViewWindowId;
if (webView != null) {
webViewWindowId = webView.windowId;
assert(webViewWindowId !=
null, "If you are returning a WebView, then WebView.windowId should be not null. To set the " +
"WebView.windowId property, you should use the CreateWindowRequest.windowId property.");
assert(
webViewWindowId != null,
"If you are returning a WebView, then WebView.windowId should be not null. To set the " +
"WebView.windowId property, you should use the CreateWindowRequest.windowId property.");
if (webView is HeadlessInAppWebView) {
webView.run();
}
} else if (inAppBrowserWindow != null) {
if (inAppBrowserWindow is InAppBrowser) {
webViewWindowId = inAppBrowserWindow.windowId;
assert(webViewWindowId !=
null, "If you are returning an InAppBrowser, then InAppBrowser.windowId should be not null. To set the " +
"InAppBrowser.windowId property, you should use the CreateWindowRequest.windowId property.");
assert(
webViewWindowId != null,
"If you are returning an InAppBrowser, then InAppBrowser.windowId should be not null. To set the " +
"InAppBrowser.windowId property, you should use the CreateWindowRequest.windowId property.");
inAppBrowserWindow.openUrl(url: "about:blank");
}
else if (inAppBrowserWindow is HeadlessInAppWebView) {
} else if (inAppBrowserWindow is HeadlessInAppWebView) {
webViewWindowId = inAppBrowserWindow.windowId;
assert(webViewWindowId !=
null, "If you are returning a HeadlessInAppWebView, then HeadlessInAppWebView.windowId should be not null. To set the " +
"HeadlessInAppWebView.windowId property, you should use the CreateWindowRequest.windowId property.");
assert(
webViewWindowId != null,
"If you are returning a HeadlessInAppWebView, then HeadlessInAppWebView.windowId should be not null. To set the " +
"HeadlessInAppWebView.windowId property, you should use the CreateWindowRequest.windowId property.");
inAppBrowserWindow.run();
}
}
@ -266,15 +269,13 @@ class InAppWebViewController {
case "onCloseWindow":
if (_webview != null && _webview.onCloseWindow != null)
_webview.onCloseWindow(this);
else if (_inAppBrowser != null)
_inAppBrowser.onCloseWindow();
else if (_inAppBrowser != null) _inAppBrowser.onCloseWindow();
break;
case "onTitleChanged":
String title = call.arguments["title"];
if (_webview != null && _webview.onTitleChanged != null)
_webview.onTitleChanged(this, title);
else if (_inAppBrowser != null)
_inAppBrowser.onTitleChanged(title);
else if (_inAppBrowser != null) _inAppBrowser.onTitleChanged(title);
break;
case "onGeolocationPermissionsShowPrompt":
String origin = call.arguments["origin"];
@ -369,8 +370,7 @@ class InAppWebViewController {
case "onRequestFocus":
if (_webview != null && _webview.androidOnRequestFocus != null)
_webview.androidOnRequestFocus(this);
else if (_inAppBrowser != null)
_inAppBrowser.androidOnRequestFocus();
else if (_inAppBrowser != null) _inAppBrowser.androidOnRequestFocus();
break;
case "onReceivedIcon":
Uint8List icon = Uint8List.fromList(call.arguments["icon"].cast<int>());
@ -394,10 +394,7 @@ class InAppWebViewController {
bool iosIsMainFrame = call.arguments["iosIsMainFrame"];
JsAlertRequest jsAlertRequest = JsAlertRequest(
url: url,
message: message,
iosIsMainFrame: iosIsMainFrame
);
url: url, message: message, iosIsMainFrame: iosIsMainFrame);
if (_webview != null && _webview.onJsAlert != null)
return (await _webview.onJsAlert(this, jsAlertRequest))?.toMap();
@ -410,10 +407,7 @@ class InAppWebViewController {
bool iosIsMainFrame = call.arguments["iosIsMainFrame"];
JsConfirmRequest jsConfirmRequest = JsConfirmRequest(
url: url,
message: message,
iosIsMainFrame: iosIsMainFrame
);
url: url, message: message, iosIsMainFrame: iosIsMainFrame);
if (_webview != null && _webview.onJsConfirm != null)
return (await _webview.onJsConfirm(this, jsConfirmRequest))?.toMap();
@ -430,15 +424,12 @@ class InAppWebViewController {
url: url,
message: message,
defaultValue: defaultValue,
iosIsMainFrame: iosIsMainFrame
);
iosIsMainFrame: iosIsMainFrame);
if (_webview != null && _webview.onJsPrompt != null)
return (await _webview.onJsPrompt(this, jsPromptRequest))
?.toMap();
return (await _webview.onJsPrompt(this, jsPromptRequest))?.toMap();
else if (_inAppBrowser != null)
return (await _inAppBrowser.onJsPrompt(jsPromptRequest))
?.toMap();
return (await _inAppBrowser.onJsPrompt(jsPromptRequest))?.toMap();
break;
case "onJsBeforeUnload":
String url = call.arguments["url"];
@ -446,17 +437,18 @@ class InAppWebViewController {
bool iosIsMainFrame = call.arguments["iosIsMainFrame"];
JsBeforeUnloadRequest jsBeforeUnloadRequest = JsBeforeUnloadRequest(
url: url,
message: message,
iosIsMainFrame: iosIsMainFrame
);
url: url, message: message, iosIsMainFrame: iosIsMainFrame);
print(jsBeforeUnloadRequest);
if (_webview != null && _webview.androidOnJsBeforeUnload != null)
return (await _webview.androidOnJsBeforeUnload(this, jsBeforeUnloadRequest))?.toMap();
return (await _webview.androidOnJsBeforeUnload(
this, jsBeforeUnloadRequest))
?.toMap();
else if (_inAppBrowser != null)
return (await _inAppBrowser.androidOnJsBeforeUnload(jsBeforeUnloadRequest))?.toMap();
return (await _inAppBrowser
.androidOnJsBeforeUnload(jsBeforeUnloadRequest))
?.toMap();
break;
case "onSafeBrowsingHit":
String url = call.arguments["url"];
@ -475,11 +467,8 @@ class InAppWebViewController {
String account = call.arguments["account"];
String args = call.arguments["args"];
LoginRequest loginRequest = LoginRequest(
realm: realm,
account: account,
args: args
);
LoginRequest loginRequest =
LoginRequest(realm: realm, account: account, args: args);
if (_webview != null && _webview.androidOnReceivedLoginRequest != null)
_webview.androidOnReceivedLoginRequest(this, loginRequest);
@ -942,14 +931,12 @@ class InAppWebViewController {
case "onWindowFocus":
if (_webview != null && _webview.onWindowFocus != null)
_webview.onWindowFocus(this);
else if (_inAppBrowser != null)
_inAppBrowser.onWindowFocus();
else if (_inAppBrowser != null) _inAppBrowser.onWindowFocus();
return null;
case "onWindowBlur":
if (_webview != null && _webview.onWindowBlur != null)
_webview.onWindowBlur(this);
else if (_inAppBrowser != null)
_inAppBrowser.onWindowBlur();
else if (_inAppBrowser != null) _inAppBrowser.onWindowBlur();
return null;
}

View File

@ -450,11 +450,7 @@ class JsAlertRequest {
///Indicates whether the request was made for the main frame. Available only on iOS.
bool iosIsMainFrame;
JsAlertRequest({
this.url,
this.message,
this.iosIsMainFrame
});
JsAlertRequest({this.url, this.message, this.iosIsMainFrame});
Map<String, dynamic> toMap() {
return {"url": url, "message": message, "iosIsMainFrame": iosIsMainFrame};
@ -536,11 +532,7 @@ class JsConfirmRequest {
///Indicates whether the request was made for the main frame. Available only on iOS.
bool iosIsMainFrame;
JsConfirmRequest({
this.url,
this.message,
this.iosIsMainFrame
});
JsConfirmRequest({this.url, this.message, this.iosIsMainFrame});
Map<String, dynamic> toMap() {
return {"url": url, "message": message, "iosIsMainFrame": iosIsMainFrame};
@ -631,15 +623,16 @@ class JsPromptRequest {
///Indicates whether the request was made for the main frame. Available only on iOS.
bool iosIsMainFrame;
JsPromptRequest({
this.url,
this.message,
this.defaultValue,
this.iosIsMainFrame
});
JsPromptRequest(
{this.url, this.message, this.defaultValue, this.iosIsMainFrame});
Map<String, dynamic> toMap() {
return {"url": url, "message": message, "defaultValue": defaultValue, "iosIsMainFrame": iosIsMainFrame};
return {
"url": url,
"message": message,
"defaultValue": defaultValue,
"iosIsMainFrame": iosIsMainFrame
};
}
Map<String, dynamic> toJson() {
@ -734,11 +727,7 @@ class JsBeforeUnloadRequest {
///Indicates whether the request was made for the main frame. Available only on iOS.
bool iosIsMainFrame;
JsBeforeUnloadRequest({
this.url,
this.message,
this.iosIsMainFrame
});
JsBeforeUnloadRequest({this.url, this.message, this.iosIsMainFrame});
Map<String, dynamic> toMap() {
return {"url": url, "message": message, "iosIsMainFrame": iosIsMainFrame};
@ -790,10 +779,10 @@ class JsBeforeUnloadResponse {
JsBeforeUnloadResponse(
{this.message = "",
this.handledByClient = false,
this.confirmButtonTitle = "",
this.cancelButtonTitle = "",
this.action = JsBeforeUnloadResponseAction.CONFIRM});
this.handledByClient = false,
this.confirmButtonTitle = "",
this.cancelButtonTitle = "",
this.action = JsBeforeUnloadResponseAction.CONFIRM});
Map<String, dynamic> toMap() {
return {
@ -3151,7 +3140,7 @@ class CreateWindowRequest {
///The window id. Used by [WebView] to create a new WebView.
int windowId;
///Indicates if the new window should be a dialog, rather than a full-size window. Available only on Android.
bool androidIsDialog;
@ -4376,18 +4365,10 @@ class LoginRequest {
///Authenticator specific arguments used to log in the user.
String args;
LoginRequest({
this.realm,
this.account,
this.args
});
LoginRequest({this.realm, this.account, this.args});
Map<String, dynamic> toMap() {
return {
"realm": realm,
"account": account,
"args": args
};
return {"realm": realm, "account": account, "args": args};
}
Map<String, dynamic> toJson() {
@ -4398,4 +4379,4 @@ class LoginRequest {
String toString() {
return toMap().toString();
}
}
}

View File

@ -187,7 +187,8 @@ abstract class WebView {
///
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview
final Future<JsAlertResponse> Function(
InAppWebViewController controller, JsAlertRequest jsAlertRequest) onJsAlert;
InAppWebViewController controller, JsAlertRequest jsAlertRequest)
onJsAlert;
///Event fired when javascript calls the `confirm()` method to display a confirm dialog.
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
@ -198,7 +199,8 @@ abstract class WebView {
///
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview
final Future<JsConfirmResponse> Function(
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest) onJsConfirm;
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)
onJsConfirm;
///Event fired when javascript calls the `prompt()` method to display a prompt dialog.
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
@ -208,8 +210,9 @@ abstract class WebView {
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)
///
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview
final Future<JsPromptResponse> Function(InAppWebViewController controller,
JsPromptRequest jsPromptRequest) onJsPrompt;
final Future<JsPromptResponse> Function(
InAppWebViewController controller, JsPromptRequest jsPromptRequest)
onJsPrompt;
///Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
///
@ -381,7 +384,7 @@ abstract class WebView {
///
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)
final void Function(InAppWebViewController controller, String title)
onTitleChanged;
onTitleChanged;
///Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing.
///The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
@ -539,7 +542,8 @@ abstract class WebView {
///**NOTE**: available only on Android.
///
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)
final void Function(InAppWebViewController controller, Uint8List icon) androidOnReceivedIcon;
final void Function(InAppWebViewController controller, Uint8List icon)
androidOnReceivedIcon;
///Event fired when there is an url for an apple-touch-icon.
///
@ -550,7 +554,9 @@ abstract class WebView {
///**NOTE**: available only on Android.
///
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)
final void Function(InAppWebViewController controller, String url, bool precomposed) androidOnReceivedTouchIconUrl;
final void Function(
InAppWebViewController controller, String url, bool precomposed)
androidOnReceivedTouchIconUrl;
///Event fired when the client should display a dialog to confirm navigation away from the current page.
///This is the result of the `onbeforeunload` javascript event.
@ -566,7 +572,8 @@ abstract class WebView {
///
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)
final Future<JsBeforeUnloadResponse> Function(
InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest) androidOnJsBeforeUnload;
InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest) androidOnJsBeforeUnload;
///Event fired when a request to automatically log in the user has been processed.
///
@ -575,7 +582,9 @@ abstract class WebView {
///**NOTE**: available only on Android.
///
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String)
final void Function(InAppWebViewController controller, LoginRequest loginRequest) androidOnReceivedLoginRequest;
final void Function(
InAppWebViewController controller, LoginRequest loginRequest)
androidOnReceivedLoginRequest;
///Invoked when the web view's web content process is terminated.
///