File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## 1.2.0
2+ * Added support for HTML string loading
3+
14## 1.1.2
25* Removed redundant isolate uses
36* Removed flutter version constraint in pubspec.yaml
Original file line number Diff line number Diff line change @@ -46,18 +46,22 @@ It's better to warm up the controller before displaying the webview. It's possib
4646 Supported params of [ AdBlockerWebview] ( https://pub.dev/documentation/adblocker_webview/latest/adblocker_webview/AdBlockerWebview-class.html] ) are:
4747 ``` dart
4848 const AdBlockerWebview({
49- super.key,
50- required this.url,
51- required this.adBlockerWebviewController,
52- required this.shouldBlockAds,
53- this.onLoadStart,
54- this.onLoadFinished,
55- this.onProgress,
56- this.onLoadError,
57- this.onTitleChanged,
58- this.options,
59- this.additionalHostsToBlock = const [],
60- });
49+ required this.adBlockerWebviewController,
50+ required this.shouldBlockAds,
51+ this.url,
52+ this.initialHtmlData,
53+ this.onLoadStart,
54+ this.onLoadFinished,
55+ this.onProgress,
56+ this.onLoadError,
57+ this.onTitleChanged,
58+ this.options,
59+ this.additionalHostsToBlock = const [],
60+ super.key,
61+ }) : assert(
62+ (url == null && initialHtmlData != null) ||
63+ (url != null && initialHtmlData == null),
64+ 'Both url and initialHtmlData can not be non null');
6165```
6266#### Caching
6367- API response for Ad hosts is cached automatically and no config is required!
Original file line number Diff line number Diff line change @@ -8,21 +8,27 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
88/// appear inside of the webpages.
99class AdBlockerWebview extends StatefulWidget {
1010 const AdBlockerWebview ({
11- required this .url,
1211 required this .adBlockerWebviewController,
1312 required this .shouldBlockAds,
14- super .key,
13+ this .url,
14+ this .initialHtmlData,
1515 this .onLoadStart,
1616 this .onLoadFinished,
1717 this .onProgress,
1818 this .onLoadError,
1919 this .onTitleChanged,
2020 this .options,
2121 this .additionalHostsToBlock = const [],
22- });
22+ super .key,
23+ }) : assert (
24+ (url == null && initialHtmlData != null ) ||
25+ (url != null && initialHtmlData == null ),
26+ 'Both url and initialHtmlData can not be non null' );
2327
2428 /// Required: The initial [Uri] url that will be displayed in webview.
25- final Uri url;
29+ final Uri ? url;
30+
31+ final String ? initialHtmlData;
2632
2733 /// Required: The controller for [AdBlockerWebview] .
2834 /// See more at [AdBlockerWebviewController] .
@@ -110,6 +116,9 @@ class _AdBlockerWebviewState extends State<AdBlockerWebview> {
110116 onLoadStop: widget.onLoadFinished,
111117 onLoadError: widget.onLoadError,
112118 onTitleChanged: widget.onTitleChanged,
119+ initialData: widget.initialHtmlData == null
120+ ? null
121+ : InAppWebViewInitialData (data: widget.initialHtmlData! ),
113122 );
114123 }
115124}
Original file line number Diff line number Diff line change @@ -55,6 +55,12 @@ abstract class AdBlockerWebviewController implements InternalWebviewController {
5555 // Loads the given url
5656 Future <void > loadUrl (String url);
5757
58+ Future <void > loadData (
59+ String data, {
60+ String mimeType = 'text/html' ,
61+ String encoding = 'utf8' ,
62+ });
63+
5864 /// Navigates webview to previous page
5965 Future <void > goBack ();
6066
Original file line number Diff line number Diff line change @@ -97,6 +97,22 @@ class AdBlockerWebviewControllerImpl implements AdBlockerWebviewController {
9797 .loadUrl (urlRequest: URLRequest (url: Uri .parse (url)));
9898 }
9999
100+ @override
101+ Future <void > loadData (
102+ String data, {
103+ String mimeType = 'text/html' ,
104+ String encoding = 'utf8' ,
105+ }) async {
106+ if (_inAppWebViewController == null ) {
107+ return ;
108+ }
109+ return _inAppWebViewController! .loadData (
110+ data: data,
111+ mimeType: mimeType,
112+ encoding: encoding,
113+ );
114+ }
115+
100116 @override
101117 Future <void > reload () async {
102118 if (_inAppWebViewController == null ) {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: adblocker_webview
22description : A webview for flutter with adblocking capability. It's currently based on Flutter InAppWebview Plugin.
33repository : https://github.com/islamdidarmd/flutter_adblocker_webview
44issue_tracker : https://github.com/islamdidarmd/flutter_adblocker_webview/issues
5- version : 1.1.2
5+ version : 1.2.0
66homepage : https://github.com/islamdidarmd/flutter_adblocker_webview
77
88environment :
You can’t perform that action at this time.
0 commit comments