code format

This commit is contained in:
Lorenzo Pichilli 2023-11-11 19:09:10 +01:00
parent 18c3c1fa51
commit d5a0bb3e3e
21 changed files with 152 additions and 179 deletions

View File

@ -295,7 +295,8 @@ class ChromeSafariBrowser extends ChannelController {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('relation', () => relation.toNativeValue());
args.putIfAbsent('origin', () => origin.toString());
return await channel?.invokeMethod<bool>("validateRelationship", args) ?? false;
return await channel?.invokeMethod<bool>("validateRelationship", args) ??
false;
}
///Closes the [ChromeSafariBrowser] instance.
@ -401,7 +402,8 @@ class ChromeSafariBrowser extends ChannelController {
///- Android
static Future<int> getMaxToolbarItems() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _sharedChannel.invokeMethod<int>("getMaxToolbarItems", args) ?? 0;
return await _sharedChannel.invokeMethod<int>("getMaxToolbarItems", args) ??
0;
}
///Clear associated website data accrued from browsing activity within your app.

View File

@ -70,8 +70,7 @@ class InAppBrowser extends ChannelController {
}
_init() {
channel =
MethodChannel('com.pichillilorenzo/flutter_inappbrowser_$id');
channel = MethodChannel('com.pichillilorenzo/flutter_inappbrowser_$id');
handler = _handleMethod;
initMethodCallHandler();

View File

@ -86,7 +86,9 @@ class InAppLocalhostServer {
path = _documentRoot + path;
try {
body = (await rootBundle.load(Uri.decodeFull(path))).buffer.asUint8List();
body = (await rootBundle.load(Uri.decodeFull(path)))
.buffer
.asUint8List();
} catch (e) {
print(e.toString());
request.response.close();

View File

@ -29,7 +29,8 @@ import '../types/disposable.dart';
///- Web
///- MacOS
///{@endtemplate}
class HeadlessInAppWebView extends ChannelController implements WebView, Disposable {
class HeadlessInAppWebView extends ChannelController
implements WebView, Disposable {
///View ID.
late final String id;
@ -68,8 +69,7 @@ class HeadlessInAppWebView extends ChannelController implements WebView, Disposa
this.initialUrlRequest,
this.initialFile,
this.initialData,
@Deprecated('Use initialSettings instead')
this.initialOptions,
@Deprecated('Use initialSettings instead') this.initialOptions,
this.initialSettings,
this.contextMenu,
this.initialUserScripts,
@ -78,19 +78,16 @@ class HeadlessInAppWebView extends ChannelController implements WebView, Disposa
this.onWebViewCreated,
this.onLoadStart,
this.onLoadStop,
@Deprecated("Use onReceivedError instead")
this.onLoadError,
@Deprecated("Use onReceivedError instead") this.onLoadError,
this.onReceivedError,
@Deprecated("Use onReceivedHttpError instead")
this.onLoadHttpError,
@Deprecated("Use onReceivedHttpError instead") this.onLoadHttpError,
this.onReceivedHttpError,
this.onProgressChanged,
this.onConsoleMessage,
this.shouldOverrideUrlLoading,
this.onLoadResource,
this.onScrollChanged,
@Deprecated('Use onDownloadStartRequest instead')
this.onDownloadStart,
@Deprecated('Use onDownloadStartRequest instead') this.onDownloadStart,
this.onDownloadStartRequest,
@Deprecated('Use onLoadResourceWithCustomScheme instead')
this.onLoadResourceCustomScheme,
@ -110,8 +107,7 @@ class HeadlessInAppWebView extends ChannelController implements WebView, Disposa
this.onAjaxProgress,
this.shouldInterceptFetchRequest,
this.onUpdateVisitedHistory,
@Deprecated("Use onPrintRequest instead")
this.onPrint,
@Deprecated("Use onPrintRequest instead") this.onPrint,
this.onPrintRequest,
this.onLongPressHitTestResult,
this.onEnterFullscreen,
@ -148,16 +144,13 @@ class HeadlessInAppWebView extends ChannelController implements WebView, Disposa
@Deprecated('Use onFormResubmission instead')
this.androidOnFormResubmission,
this.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead')
this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead')
this.androidOnReceivedIcon,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon,
this.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead')
this.androidOnReceivedTouchIconUrl,
this.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead')
this.androidOnJsBeforeUnload,
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload,
this.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead')
this.androidOnReceivedLoginRequest,
@ -167,7 +160,8 @@ class HeadlessInAppWebView extends ChannelController implements WebView, Disposa
@Deprecated('Use onWebContentProcessDidTerminate instead')
this.iosOnWebContentProcessDidTerminate,
this.onWebContentProcessDidTerminate,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
@Deprecated(
'Use onDidReceiveServerRedirectForProvisionalNavigation instead')
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead')
@ -364,8 +358,7 @@ class HeadlessInAppWebView extends ChannelController implements WebView, Disposa
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic> sizeMap =
(await channel?.invokeMethod('getSize', args))
?.cast<String, dynamic>();
(await channel?.invokeMethod('getSize', args))?.cast<String, dynamic>();
return MapSize.fromMap(sizeMap);
}

View File

@ -171,7 +171,8 @@ class InAppWebView extends StatefulWidget implements WebView {
@Deprecated('Use onWebContentProcessDidTerminate instead')
this.iosOnWebContentProcessDidTerminate,
this.onWebContentProcessDidTerminate,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
@Deprecated(
'Use onDidReceiveServerRedirectForProvisionalNavigation instead')
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead')

View File

@ -1197,19 +1197,16 @@ abstract class WebView {
this.onWebViewCreated,
this.onLoadStart,
this.onLoadStop,
@Deprecated('Use onReceivedError instead')
this.onLoadError,
@Deprecated('Use onReceivedError instead') this.onLoadError,
this.onReceivedError,
@Deprecated("Use onReceivedHttpError instead")
this.onLoadHttpError,
@Deprecated("Use onReceivedHttpError instead") this.onLoadHttpError,
this.onReceivedHttpError,
this.onProgressChanged,
this.onConsoleMessage,
this.shouldOverrideUrlLoading,
this.onLoadResource,
this.onScrollChanged,
@Deprecated('Use onDownloadStartRequest instead')
this.onDownloadStart,
@Deprecated('Use onDownloadStartRequest instead') this.onDownloadStart,
this.onDownloadStartRequest,
@Deprecated('Use onLoadResourceWithCustomScheme instead')
this.onLoadResourceCustomScheme,
@ -1229,8 +1226,7 @@ abstract class WebView {
this.onAjaxProgress,
this.shouldInterceptFetchRequest,
this.onUpdateVisitedHistory,
@Deprecated("Use onPrintRequest instead")
this.onPrint,
@Deprecated("Use onPrintRequest instead") this.onPrint,
this.onPrintRequest,
this.onLongPressHitTestResult,
this.onEnterFullscreen,
@ -1268,16 +1264,13 @@ abstract class WebView {
@Deprecated('Use onFormResubmission instead')
this.androidOnFormResubmission,
this.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead')
this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead')
this.androidOnReceivedIcon,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon,
this.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead')
this.androidOnReceivedTouchIconUrl,
this.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead')
this.androidOnJsBeforeUnload,
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload,
this.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead')
this.androidOnReceivedLoginRequest,
@ -1287,7 +1280,8 @@ abstract class WebView {
@Deprecated('Use onWebContentProcessDidTerminate instead')
this.iosOnWebContentProcessDidTerminate,
this.onWebContentProcessDidTerminate,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
@Deprecated(
'Use onDidReceiveServerRedirectForProvisionalNavigation instead')
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead')
@ -1302,8 +1296,7 @@ abstract class WebView {
this.initialUrlRequest,
this.initialFile,
this.initialData,
@Deprecated('Use initialSettings instead')
this.initialOptions,
@Deprecated('Use initialSettings instead') this.initialOptions,
this.initialSettings,
this.contextMenu,
this.initialUserScripts,

View File

@ -93,8 +93,7 @@ class PrintJobController extends ChannelController {
Future<PrintJobInfo?> getInfo() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? infoMap =
(await channel?.invokeMethod('getInfo', args))
?.cast<String, dynamic>();
(await channel?.invokeMethod('getInfo', args))?.cast<String, dynamic>();
return PrintJobInfo.fromMap(infoMap);
}

View File

@ -176,7 +176,9 @@ class PullToRefreshController extends ChannelController {
///- Android native WebView ([Official API - SwipeRefreshLayout.DEFAULT_SLINGSHOT_DISTANCE](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#DEFAULT_SLINGSHOT_DISTANCE()))
Future<int> getDefaultSlingshotDistance() async {
Map<String, dynamic> args = <String, dynamic>{};
return await channel?.invokeMethod<int>('getDefaultSlingshotDistance', args) ?? 0;
return await channel?.invokeMethod<int>(
'getDefaultSlingshotDistance', args) ??
0;
}
///Use [setIndicatorSize] instead.

View File

@ -42,18 +42,14 @@ class CreateWindowAction_ extends NavigationAction_ {
CreateWindowAction_(
{required this.windowId,
@Deprecated('Use isDialog instead')
this.androidIsDialog,
@Deprecated('Use isDialog instead') this.androidIsDialog,
this.isDialog,
@Deprecated('Use windowFeatures instead')
this.iosWindowFeatures,
@Deprecated('Use windowFeatures instead') this.iosWindowFeatures,
this.windowFeatures,
required URLRequest_ request,
required bool isForMainFrame,
@Deprecated('Use hasGesture instead')
bool? androidHasGesture,
@Deprecated('Use isRedirect instead')
bool? androidIsRedirect,
@Deprecated('Use hasGesture instead') bool? androidHasGesture,
@Deprecated('Use isRedirect instead') bool? androidIsRedirect,
bool? hasGesture,
bool? isRedirect,
@Deprecated('Use navigationType instead')

View File

@ -32,29 +32,23 @@ class CreateWindowAction extends NavigationAction {
///The window id. Used by [WebView] to create a new WebView.
int windowId;
CreateWindowAction(
{@Deprecated('Use isDialog instead')
this.androidIsDialog,
@Deprecated('Use windowFeatures instead')
this.iosWindowFeatures,
{@Deprecated('Use isDialog instead') this.androidIsDialog,
@Deprecated('Use windowFeatures instead') this.iosWindowFeatures,
this.isDialog,
this.windowFeatures,
required this.windowId,
required URLRequest request,
required bool isForMainFrame,
@Deprecated('Use hasGesture instead')
bool? androidHasGesture,
@Deprecated('Use hasGesture instead') bool? androidHasGesture,
bool? hasGesture,
@Deprecated('Use isRedirect instead')
bool? androidIsRedirect,
@Deprecated('Use isRedirect instead') bool? androidIsRedirect,
bool? isRedirect,
@Deprecated('Use navigationType instead')
IOSWKNavigationType? iosWKNavigationType,
NavigationType? navigationType,
@Deprecated('Use sourceFrame instead')
IOSWKFrameInfo? iosSourceFrame,
@Deprecated('Use sourceFrame instead') IOSWKFrameInfo? iosSourceFrame,
FrameInfo? sourceFrame,
@Deprecated('Use targetFrame instead')
IOSWKFrameInfo? iosTargetFrame,
@Deprecated('Use targetFrame instead') IOSWKFrameInfo? iosTargetFrame,
FrameInfo? targetFrame,
bool? shouldPerformDownload})
: super(

View File

@ -134,13 +134,11 @@ class URLProtectionSpace_ {
@Deprecated("Use authenticationMethod instead")
this.iosAuthenticationMethod,
this.authenticationMethod,
@Deprecated("Use distinguishedNames instead")
this.iosDistinguishedNames,
@Deprecated("Use distinguishedNames instead") this.iosDistinguishedNames,
this.distinguishedNames,
@Deprecated("Use receivesCredentialSecurely instead")
this.iosReceivesCredentialSecurely,
this.receivesCredentialSecurely,
@Deprecated("Use proxyType instead")
this.iosProxyType,
@Deprecated("Use proxyType instead") this.iosProxyType,
this.proxyType});
}

View File

@ -82,10 +82,8 @@ class URLProtectionSpace {
required this.host,
@Deprecated('Use authenticationMethod instead')
this.iosAuthenticationMethod,
@Deprecated('Use distinguishedNames instead')
this.iosDistinguishedNames,
@Deprecated('Use proxyType instead')
this.iosProxyType,
@Deprecated('Use distinguishedNames instead') this.iosDistinguishedNames,
@Deprecated('Use proxyType instead') this.iosProxyType,
@Deprecated('Use receivesCredentialSecurely instead')
this.iosReceivesCredentialSecurely,
this.port,

View File

@ -231,8 +231,7 @@ class URLRequest_ {
@Deprecated("Use allowsExpensiveNetworkAccess instead")
this.iosAllowsExpensiveNetworkAccess,
this.allowsExpensiveNetworkAccess,
@Deprecated("Use cachePolicy instead")
this.iosCachePolicy,
@Deprecated("Use cachePolicy instead") this.iosCachePolicy,
this.cachePolicy,
@Deprecated("Use httpShouldHandleCookies instead")
this.iosHttpShouldHandleCookies,
@ -240,14 +239,11 @@ class URLRequest_ {
@Deprecated("Use httpShouldUsePipelining instead")
this.iosHttpShouldUsePipelining,
this.httpShouldUsePipelining,
@Deprecated("Use networkServiceType instead")
this.iosNetworkServiceType,
@Deprecated("Use networkServiceType instead") this.iosNetworkServiceType,
this.networkServiceType,
@Deprecated("Use timeoutInterval instead")
this.iosTimeoutInterval,
@Deprecated("Use timeoutInterval instead") this.iosTimeoutInterval,
this.timeoutInterval,
@Deprecated("Use mainDocumentURL instead")
this.iosMainDocumentURL,
@Deprecated("Use mainDocumentURL instead") this.iosMainDocumentURL,
this.mainDocumentURL,
this.assumesHTTP3Capable,
this.attribution});

View File

@ -156,18 +156,14 @@ class URLRequest {
this.iosAllowsConstrainedNetworkAccess,
@Deprecated('Use allowsExpensiveNetworkAccess instead')
this.iosAllowsExpensiveNetworkAccess,
@Deprecated('Use cachePolicy instead')
this.iosCachePolicy,
@Deprecated('Use cachePolicy instead') this.iosCachePolicy,
@Deprecated('Use httpShouldHandleCookies instead')
this.iosHttpShouldHandleCookies,
@Deprecated('Use httpShouldUsePipelining instead')
this.iosHttpShouldUsePipelining,
@Deprecated('Use mainDocumentURL instead')
this.iosMainDocumentURL,
@Deprecated('Use networkServiceType instead')
this.iosNetworkServiceType,
@Deprecated('Use timeoutInterval instead')
this.iosTimeoutInterval,
@Deprecated('Use mainDocumentURL instead') this.iosMainDocumentURL,
@Deprecated('Use networkServiceType instead') this.iosNetworkServiceType,
@Deprecated('Use timeoutInterval instead') this.iosTimeoutInterval,
this.mainDocumentURL,
this.method,
this.networkServiceType,

View File

@ -605,22 +605,25 @@ abstract class ChannelController implements Disposable {
}
extension InternalChannelController on ChannelController {
set channel (MethodChannel? channel) => _channel = channel;
set channel(MethodChannel? channel) => _channel = channel;
MethodChannel? get channel {
assert(ChannelController.debugAssertNotDisposed(this));
return this._channel;
}
set handler (Future<dynamic> Function(MethodCall call)? handler) => _handler = handler;
set handler(Future<dynamic> Function(MethodCall call)? handler) =>
_handler = handler;
Future<dynamic> Function(MethodCall call)? get handler => _handler;
bool get disposed => _channel == null;
initMethodCallHandler() {
assert(channel != null, 'Method Channel for ${runtimeType} not initialized!');
assert(handler != null, 'Method Call Handler for ${runtimeType} not initialized!');
assert(
channel != null, 'Method Channel for ${runtimeType} not initialized!');
assert(handler != null,
'Method Call Handler for ${runtimeType} not initialized!');
channel?.setMethodCallHandler((call) async {
if (disposed) return null;

View File

@ -186,6 +186,7 @@ class WebAuthenticationSession extends ChannelController {
///- iOS
static Future<bool> isAvailable() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _sharedChannel.invokeMethod<bool>("isAvailable", args) ?? false;
return await _sharedChannel.invokeMethod<bool>("isAvailable", args) ??
false;
}
}

View File

@ -43,7 +43,7 @@ class WebMessageListener extends ChannelController {
allowedOriginRules != null ? allowedOriginRules : Set.from(["*"]);
assert(!this.allowedOriginRules.contains(""),
"allowedOriginRules cannot contain empty strings");
channel= MethodChannel(
channel = MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_web_message_listener_${id}_$jsObjectName');
handler = _handleMethod;
initMethodCallHandler();