diff --git a/example/lib/webview_page.dart b/example/lib/webview_page.dart index 01e41b3..af3a42d 100644 --- a/example/lib/webview_page.dart +++ b/example/lib/webview_page.dart @@ -47,7 +47,7 @@ class _WebViewXPageState extends State { padding: const EdgeInsets.only(bottom: 20.0), child: Text( 'Play around with the buttons below', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.titleLarge, ), ), buildSpace(direction: Axis.vertical, amount: 10.0, flex: false), @@ -59,7 +59,7 @@ class _WebViewXPageState extends State { ), Expanded( child: Scrollbar( - isAlwaysShown: true, + thumbVisibility: true, child: SizedBox( width: min(screenSize.width * 0.8, 512), child: ListView( diff --git a/example/pubspec.lock b/example/pubspec.lock index 9f356e2..61e1fd4 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,65 +5,82 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.12.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: "8e36feea6de5ea69f2199f29cf42a450a855738c498b57c0b980e2d3cca9c362" + url: "https://pub.dev" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.19.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c + url: "https://pub.dev" source: hosted version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8" + url: "https://pub.dev" source: hosted version: "1.0.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.2" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" flutter: dependency: "direct main" description: flutter @@ -78,131 +95,197 @@ packages: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: b6f1f143a71e1fe1b34670f1acd6f13960ade2557c96b87e127e0cf661969791 + url: "https://pub.dev" source: hosted version: "0.13.3" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec + url: "https://pub.dev" + source: hosted + version: "10.0.8" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + url: "https://pub.dev" + source: hosted + version: "3.0.9" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lint: dependency: "direct dev" description: name: lint - url: "https://pub.dartlang.org" + sha256: "89071bd470cbfcb69c890d94092fc3af947f7c4e3e880f7c82b2988fd348189e" + url: "https://pub.dev" source: hosted version: "1.6.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.11.1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.16.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "8f6460c77a98ad2807cd3b98c67096db4286f56166852d0ce5951bb600a63594" + url: "https://pub.dev" source: hosted version: "1.11.0" pointer_interceptor: dependency: transitive description: name: pointer_interceptor - url: "https://pub.dartlang.org" + sha256: ec3030cee582f0eae2694917652e7ccf906e5e7bd1749febf68f09af3fd48340 + url: "https://pub.dev" source: hosted version: "0.9.0+1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.1" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.1" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.7.4" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" uuid: dependency: transitive description: name: uuid - url: "https://pub.dartlang.org" + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff + url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "4.5.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "14.3.1" webview_flutter: dependency: transitive description: name: webview_flutter - url: "https://pub.dartlang.org" + sha256: "065b52f7d10520db76c598fc50a07d2ab4596b9e0960c59da6653fc7d41c6650" + url: "https://pub.dev" source: hosted version: "2.0.13" webviewx: @@ -213,5 +296,5 @@ packages: source: path version: "0.2.1" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=3.7.0-0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/lib/src/controller/impl/mobile.dart b/lib/src/controller/impl/mobile.dart index d3c2be9..03de5cb 100644 --- a/lib/src/controller/impl/mobile.dart +++ b/lib/src/controller/impl/mobile.dart @@ -95,6 +95,20 @@ class WebViewXController extends ChangeNotifier ); } + if (sourceType == SourceType.html) { + await connector.loadHtmlString( + HtmlUtils.preprocessSource( + value.source, + jsContent: const {}, + encodeHtml: true, + ), + ); + } else { + await connector.loadRequest( + Uri.parse(value.source), + headers: headers ?? {}, + ); + } _notifyWidget(); } @@ -113,7 +127,6 @@ class WebViewXController extends ChangeNotifier /// var resultFromJs = await callJsMethod('someFunction', ['test']) /// print(resultFromJs); // prints "This is a test" /// ``` - //TODO This should return an error if the operation failed, but it doesn't @override Future callJsMethod( String name, @@ -121,7 +134,7 @@ class WebViewXController extends ChangeNotifier ) async { // This basically will transform a "raw" call (evaluateJavascript) // into a little bit more "typed" call, that is - calling a method. - final result = await connector.evaluateJavascript( + final result = await connector.runJavaScriptReturningResult( HtmlUtils.buildJsFunction(name, params), ); @@ -129,39 +142,31 @@ class WebViewXController extends ChangeNotifier // // In the mobile version responses from Js to Dart come wrapped in single quotes (') // The web works fine because it is already into it's native environment - return HtmlUtils.unQuoteJsResponseIfNeeded(result); + return result is String + ? HtmlUtils.unQuoteJsResponseIfNeeded(result) + : result; } - /// This function allows you to evaluate 'raw' javascript (e.g: 2+2) - /// If you need to call a function you should use the method above ([callJsMethod]) - /// - /// The [inGlobalContext] param should be set to true if you wish to eval your code - /// in the 'window' context, instead of doing it inside the corresponding iframe's 'window' - /// - /// For more info, check Mozilla documentation on 'window' + /// Evaluates the given JavaScript [code] in the context of the current page. @override Future evalRawJavascript( - String rawJavascript, { - bool inGlobalContext = false, // NO-OP HERE - }) { - return connector.evaluateJavascript(rawJavascript); + String code, { + bool inGlobalContext = false, + }) async { + try { + final result = await connector.runJavaScriptReturningResult(code); + return result is String + ? HtmlUtils.unQuoteJsResponseIfNeeded(result) + : result; + } catch (e) { + return null; + } } - /// Returns the current content + /// Gets the current content @override Future getContent() async { - var currentContent = await connector.currentUrl(); - var currentSourceType = value.sourceType; - - if (currentContent!.substring(0, 5) == 'data:') { - currentContent = HtmlUtils.dataUriToHtml(currentContent); - currentSourceType = SourceType.html; - } - - return value.copyWith( - source: currentContent, - sourceType: currentSourceType, - ); + return value; } /// Returns a Future that completes with the value true, if you can go @@ -171,15 +176,6 @@ class WebViewXController extends ChangeNotifier return connector.canGoBack(); } - /// Go back in the history stack. - @override - Future goBack() async { - if (await canGoBack()) { - await connector.goBack(); - value = await getContent(); - } - } - /// Returns a Future that completes with the value true, if you can go /// forward in the history stack. @override @@ -187,56 +183,94 @@ class WebViewXController extends ChangeNotifier return connector.canGoForward(); } - /// Go forward in the history stack. + /// Gets the height of the HTML content. @override - Future goForward() async { - if (await canGoForward()) { - await connector.goForward(); - final liveContent = await connector.currentUrl(); - value = value.copyWith(source: liveContent); + Future getScrollHeight() async { + final result = await evalRawJavascript( + 'document.documentElement.scrollHeight;', + ); + if (result == null) return null; + if (result is num) return result.toDouble(); + return double.tryParse(result.toString()); + } + + /// Gets the width of the HTML content. + @override + Future getScrollWidth() async { + final result = await evalRawJavascript( + 'document.documentElement.scrollWidth;', + ); + if (result == null) return null; + if (result is num) return result.toDouble(); + return double.tryParse(result.toString()); + } + + /// Reloads the current content. + @override + Future reload() async { + await connector.reload(); + } + + /// Goes back in history. + @override + Future goBack() async { + if (await connector.canGoBack()) { + await connector.goBack(); } } - /// Reload the current content. + /// Goes forward in history. @override - Future reload() { - return connector.reload(); + Future goForward() async { + if (await connector.canGoForward()) { + await connector.goForward(); + } } /// Get scroll position on X axis @override - Future getScrollX() { - return connector.getScrollX(); + Future getScrollX() async { + final result = await evalRawJavascript('window.scrollX'); + if (result is num) return result.toInt(); + return 0; } /// Get scroll position on Y axis @override - Future getScrollY() { - return connector.getScrollY(); + Future getScrollY() async { + final result = await evalRawJavascript('window.scrollY'); + if (result is num) return result.toInt(); + return 0; } /// Scrolls by `x` on X axis and by `y` on Y axis @override Future scrollBy(int x, int y) { - return connector.scrollBy(x, y); + return connector.runJavaScript( + 'window.scrollBy($x, $y)', + ); } /// Scrolls exactly to the position `(x, y)` @override Future scrollTo(int x, int y) { - return connector.scrollTo(x, y); + return connector.runJavaScript( + 'window.scrollTo($x, $y)', + ); } /// Retrieves the inner page title @override - Future getTitle() { - return connector.getTitle(); + Future getTitle() async { + final result = await evalRawJavascript('document.title'); + return result?.toString(); } /// Clears cache @override - Future clearCache() { - return connector.clearCache(); + Future clearCache() async { + await connector.clearCache(); + await connector.clearLocalStorage(); } /// INTERNAL diff --git a/lib/src/controller/interface.dart b/lib/src/controller/interface.dart index ebfe75a..6a8e873 100644 --- a/lib/src/controller/interface.dart +++ b/lib/src/controller/interface.dart @@ -73,6 +73,10 @@ abstract class WebViewXController { /// in the 'window' context, instead of doing it inside the corresponding iframe's 'window' /// /// For more info, check Mozilla documentation on 'window' + /// + /// Returns the raw result from JavaScript evaluation. The type depends on the platform: + /// - On mobile (webview_flutter), it returns an Object that can be String, num, bool, List, or Map + /// - On web, it returns the raw JavaScript result Future evalRawJavascript( String rawJavascript, { bool inGlobalContext = false, diff --git a/lib/src/view/impl/mobile.dart b/lib/src/view/impl/mobile.dart index dc92ccd..7b4ffba 100644 --- a/lib/src/view/impl/mobile.dart +++ b/lib/src/view/impl/mobile.dart @@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:webviewx/src/utils/utils.dart'; -import 'package:webview_flutter/platform_interface.dart' as wf_pi; import 'package:webview_flutter/webview_flutter.dart' as wf; import 'package:webviewx/src/view/interface.dart' as view_interface; @@ -69,12 +68,15 @@ class WebViewX extends StatefulWidget implements view_interface.WebViewX { @override final bool ignoreAllGestures; - /// Boolean value to specify if Javascript execution should be allowed inside the webview + /// See [JavascriptMode]. + /// + /// Sets the JavaScript execution mode to be used by the webview. @override final JavascriptMode javascriptMode; - /// This defines if media content(audio - video) should - /// auto play when entering the page. + /// See [AutoMediaPlaybackPolicy]. + /// + /// Sets the autoMediaPlaybackPolicy for the webview. @override final AutoMediaPlaybackPolicy initialMediaPlaybackPolicy; @@ -134,120 +136,115 @@ class WebViewX extends StatefulWidget implements view_interface.WebViewX { } class _WebViewXState extends State { - late wf.WebViewController originalWebViewController; + late wf.WebViewController _webViewController; late WebViewXController webViewXController; - late bool _ignoreAllGestures; @override void initState() { super.initState(); - if (Platform.isAndroid && - widget.mobileSpecificParams.androidEnableHybridComposition) { - wf.WebView.platform = wf.SurfaceAndroidWebView(); - } - _ignoreAllGestures = widget.ignoreAllGestures; - webViewXController = _createWebViewXController(); - } - @override - Widget build(BuildContext context) { - final javascriptMode = widget.javascriptMode == JavascriptMode.unrestricted - ? wf.JavascriptMode.unrestricted - : wf.JavascriptMode.disabled; - - final initialMediaPlaybackPolicy = widget.initialMediaPlaybackPolicy == - AutoMediaPlaybackPolicy.alwaysAllow - ? wf.AutoMediaPlaybackPolicy.always_allow - : wf.AutoMediaPlaybackPolicy.require_user_action_for_all_media_types; - - void onWebResourceError(wf_pi.WebResourceError err) => - widget.onWebResourceError!( - WebResourceError( - description: err.description, - errorCode: err.errorCode, - domain: err.domain, - errorType: WebResourceErrorType.values.singleWhere( - (value) => value.toString() == err.errorType.toString(), - ), - failingUrl: err.failingUrl, - ), - ); - - FutureOr navigationDelegate( - wf.NavigationRequest request, - ) async { - if (widget.navigationDelegate == null) { - webViewXController.value = - webViewXController.value.copyWith(source: request.url); - return wf.NavigationDecision.navigate; - } - - final delegate = await widget.navigationDelegate!.call( - NavigationRequest( - content: NavigationContent( - request.url, webViewXController.value.sourceType), - isForMainFrame: request.isForMainFrame, + // Create the controller first + _webViewController = wf.WebViewController() + ..setJavaScriptMode(widget.javascriptMode == JavascriptMode.unrestricted + ? wf.JavaScriptMode.unrestricted + : wf.JavaScriptMode.disabled) + ..setBackgroundColor(Colors.transparent) + ..setNavigationDelegate( + wf.NavigationDelegate( + onPageStarted: widget.onPageStarted, + onPageFinished: widget.onPageFinished, + onWebResourceError: (err) { + if (widget.onWebResourceError != null) { + WebResourceErrorType? errorType; + try { + errorType = WebResourceErrorType.values.singleWhere( + (value) => value.toString() == err.errorType.toString(), + ); + } catch (error) { + errorType = null; + } + widget.onWebResourceError!( + WebResourceError( + description: err.description, + errorCode: err.errorCode, + errorType: errorType, + failingUrl: err.url, + ), + ); + } + }, + onNavigationRequest: widget.navigationDelegate == null + ? null + : (request) async { + final delegate = await widget.navigationDelegate!.call( + NavigationRequest( + content: NavigationContent( + request.url, webViewXController.value.sourceType), + isForMainFrame: request.isMainFrame, + ), + ); + + switch (delegate) { + case NavigationDecision.navigate: + webViewXController.value = + webViewXController.value.copyWith( + source: request.url, + ); + return wf.NavigationDecision.navigate; + case NavigationDecision.prevent: + return wf.NavigationDecision.prevent; + } + }, ), ); - switch (delegate) { - case NavigationDecision.navigate: - // When clicking on an URL, the sourceType stays the same. - // That's because you cannot move from URL to HTML just by clicking. - // Also we don't take URL_BYPASS into consideration because it has no effect here in mobile - webViewXController.value = webViewXController.value.copyWith( - source: request.url, - ); - return wf.NavigationDecision.navigate; - case NavigationDecision.prevent: - return wf.NavigationDecision.prevent; - } + // Add JavaScript channels + for (var cb in widget.dartCallBacks) { + _webViewController.addJavaScriptChannel( + cb.name, + onMessageReceived: (msg) => cb.callBack(msg.message), + ); } - void onWebViewCreated(wf.WebViewController webViewController) { - originalWebViewController = webViewController; - - webViewXController.connector = originalWebViewController; - // Calls onWebViewCreated to pass the refference upstream - if (widget.onWebViewCreated != null) { - widget.onWebViewCreated!(webViewXController); - } + // Set initial content + if (widget.initialSourceType == SourceType.html) { + _webViewController.loadHtmlString( + HtmlUtils.preprocessSource( + widget.initialContent, + jsContent: widget.jsContent, + encodeHtml: true, + ), + ); + } else { + _webViewController.loadRequest(Uri.parse(widget.initialContent)); } - final javascriptChannels = widget.dartCallBacks - .map( - (cb) => wf.JavascriptChannel( - name: cb.name, - onMessageReceived: (msg) => cb.callBack(msg.message), - ), - ) - .toSet(); + webViewXController = WebViewXController( + initialContent: widget.initialContent, + initialSourceType: widget.initialSourceType, + ignoreAllGestures: _ignoreAllGestures, + )..connector = _webViewController; + + if (widget.onWebViewCreated != null) { + widget.onWebViewCreated!(webViewXController); + } + } + @override + Widget build(BuildContext context) { return SizedBox( width: widget.width, height: widget.height, child: IgnorePointer( ignoring: _ignoreAllGestures, - child: wf.WebView( + child: wf.WebViewWidget( key: widget.key, - initialUrl: _initialContent(), - javascriptMode: javascriptMode, - onWebViewCreated: onWebViewCreated, - javascriptChannels: javascriptChannels, + controller: _webViewController, gestureRecognizers: - widget.mobileSpecificParams.mobileGestureRecognizers, - onPageStarted: widget.onPageStarted, - onPageFinished: widget.onPageFinished, - initialMediaPlaybackPolicy: initialMediaPlaybackPolicy, - onWebResourceError: onWebResourceError, - gestureNavigationEnabled: - widget.mobileSpecificParams.gestureNavigationEnabled, - debuggingEnabled: widget.mobileSpecificParams.debuggingEnabled, - navigationDelegate: navigationDelegate, - userAgent: widget.userAgent, + widget.mobileSpecificParams.mobileGestureRecognizers ?? {}, ), ), ); @@ -294,9 +291,9 @@ class _WebViewXState extends State { void _handleChange() { final newModel = webViewXController.value; - originalWebViewController.loadUrl( - _prepareContent(newModel), - headers: newModel.headers, + _webViewController.loadRequest( + Uri.parse(_prepareContent(newModel)), + headers: newModel.headers ?? {}, ); } diff --git a/pubspec.lock b/pubspec.lock index e1c3fd8..5f6b64f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,58 +5,74 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.12.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: "8e36feea6de5ea69f2199f29cf42a450a855738c498b57c0b980e2d3cca9c362" + url: "https://pub.dev" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.19.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c + url: "https://pub.dev" source: hosted version: "3.0.1" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.2" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" flutter: dependency: "direct main" description: flutter @@ -71,133 +87,231 @@ packages: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: b6f1f143a71e1fe1b34670f1acd6f13960ade2557c96b87e127e0cf661969791 + url: "https://pub.dev" source: hosted version: "0.13.3" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec + url: "https://pub.dev" + source: hosted + version: "10.0.8" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + url: "https://pub.dev" + source: hosted + version: "3.0.9" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lint: dependency: "direct dev" description: name: lint - url: "https://pub.dartlang.org" + sha256: "89071bd470cbfcb69c890d94092fc3af947f7c4e3e880f7c82b2988fd348189e" + url: "https://pub.dev" source: hosted version: "1.6.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.16.0" path: dependency: "direct main" description: name: path - url: "https://pub.dartlang.org" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor - url: "https://pub.dartlang.org" + sha256: ec3030cee582f0eae2694917652e7ccf906e5e7bd1749febf68f09af3fd48340 + url: "https://pub.dev" source: hosted version: "0.9.0+1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "7.0.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.1" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.7.4" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" uuid: dependency: "direct main" description: name: uuid - url: "https://pub.dartlang.org" + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff + url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "4.5.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "14.3.1" webview_flutter: dependency: "direct main" description: name: webview_flutter - url: "https://pub.dartlang.org" + sha256: "889a0a678e7c793c308c68739996227c9661590605e70b1f6cf6b9a6634f7aec" + url: "https://pub.dev" + source: hosted + version: "4.10.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: "512c26ccc5b8a571fd5d13ec994b7509f142ff6faf85835e243dde3538fdc713" + url: "https://pub.dev" + source: hosted + version: "4.3.2" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d + url: "https://pub.dev" + source: hosted + version: "2.10.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: d7403ef4f042714c9ee2b26eaac4cadae7394cb0d4e608b1dd850c3ff96bd893 + url: "https://pub.dev" source: hosted - version: "2.0.13" + version: "3.18.2" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=3.7.0-0 <4.0.0" + flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7a05af0..7322aca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: webviewx description: A feature-rich cross-platform webview using webview_flutter for mobile and iframe for web. JS interop-ready. homepage: https://github.com/adrianflutur/webviewx -version: 0.2.1 +version: 0.2.4 environment: sdk: ">=2.12.0 <3.0.0" @@ -14,8 +14,8 @@ dependencies: http: ^0.13.3 path: ^1.8.0 pointer_interceptor: ^0.9.0+1 - uuid: ^3.0.4 - webview_flutter: ^2.0.13 + uuid: ^4.0.0 + webview_flutter: ^4.0.0 dev_dependencies: flutter_test: