{"id":21383084,"url":"https://github.com/islamdidarmd/flutter_adblocker_webview","last_synced_at":"2025-07-13T13:31:57.507Z","repository":{"id":107608799,"uuid":"608597848","full_name":"islamdidarmd/flutter_adblocker_webview","owner":"islamdidarmd","description":"A webview implementation of in Flutter that blocks most of the ads that appear inside of the webpages","archived":false,"fork":false,"pushed_at":"2024-11-02T10:30:31.000Z","size":117,"stargazers_count":10,"open_issues_count":3,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-02T11:20:35.929Z","etag":null,"topics":["adblocker","adblocker-webview","dart","flutter","flutterdev"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/adblocker_webview","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/islamdidarmd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"buy_me_a_coffee":"islamdidarmd"}},"created_at":"2023-03-02T10:54:52.000Z","updated_at":"2024-11-02T10:23:40.000Z","dependencies_parsed_at":"2024-07-08T05:48:24.494Z","dependency_job_id":"37f86a0f-eb48-490b-80b7-5ec6c76903b2","html_url":"https://github.com/islamdidarmd/flutter_adblocker_webview","commit_stats":null,"previous_names":["islamdidarmd/adblocker_webview_flutter"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamdidarmd%2Fflutter_adblocker_webview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamdidarmd%2Fflutter_adblocker_webview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamdidarmd%2Fflutter_adblocker_webview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamdidarmd%2Fflutter_adblocker_webview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/islamdidarmd","download_url":"https://codeload.github.com/islamdidarmd/flutter_adblocker_webview/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225886580,"owners_count":17539832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adblocker","adblocker-webview","dart","flutter","flutterdev"],"created_at":"2024-11-22T11:19:46.043Z","updated_at":"2025-07-13T13:31:57.495Z","avatar_url":"https://github.com/islamdidarmd.png","language":"Dart","readme":"[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)\n\n# AdBlocker WebView Flutter\n\nA Flutter WebView implementation that blocks ads and trackers using EasyList and AdGuard filter lists.\n\n## Features\n\n- 🚫 Basic ad and tracker blocking using EasyList and AdGuard filters\n- 🌐 Supports both URL and HTML content loading\n- 🔄 Navigation control (back, forward, refresh)\n- 📱 User agent strings for Android and iOS\n- ⚡ Early resource blocking for better performance\n- 🎯 Domain-based filtering and element hiding\n- 🔍 Detailed logging of blocked resources\n- 💉 Custom JavaScript injection support\n\n## Getting Started\n\n### Installation\n\nAdd this to your `pubspec.yaml`:\n\n```yaml\ndependencies:\n  adblocker_webview: ^1.0.0\n```\n\n### Basic Usage\n\n```dart\nimport 'package:adblocker_webview/adblocker_webview.dart';\n\n// Initialize the controller (preferably in main())\nvoid main() async {\n  await AdBlockerWebviewController.instance.initialize();\n  runApp(MyApp());\n}\n\n// Use in your widget\nclass MyWebView extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return AdBlockerWebview(\n      url: Uri.parse('https://example.com'),\n      shouldBlockAds: true,\n      adBlockerWebviewController: AdBlockerWebviewController.instance,\n      onLoadStart: (url) =\u003e print('Started loading: $url'),\n      onLoadFinished: (url) =\u003e print('Finished loading: $url'),\n      onLoadError: (url, code) =\u003e print('Error: $code'),\n      onProgress: (progress) =\u003e print('Progress: $progress%'),\n    );\n  }\n}\n```\n\n### Loading HTML Content\n\n```dart\nAdBlockerWebview(\n  initialHtmlData: '\u003chtml\u003e\u003cbody\u003eHello World!\u003c/body\u003e\u003c/html\u003e',\n  shouldBlockAds: true,\n  adBlockerWebviewController: AdBlockerWebviewController.instance,\n)\n```\n\n### Navigation Control\n\n```dart\nfinal controller = AdBlockerWebviewController.instance;\n\n// Check if can go back\nif (await controller.canGoBack()) {\n  controller.goBack();\n}\n\n// Reload page\ncontroller.reload();\n\n// Execute JavaScript\ncontroller.runJavaScript('console.log(\"Hello from Flutter!\")');\n```\n\n## Configuration\n\nThe WebView can be configured with various options:\n\n```dart\nAdBlockerWebview(\n  url: Uri.parse('https://example.com'),\n  shouldBlockAds: true,  // Enable/disable ad blocking\n  adBlockerWebviewController: AdBlockerWebviewController.instance,\n  onLoadStart: (url) {\n    // Page started loading\n  },\n  onLoadFinished: (url) {\n    // Page finished loading\n  },\n  onProgress: (progress) {\n    // Loading progress (0-100)\n  },\n  onLoadError: (url, code) {\n    // Handle loading errors\n  },\n  onUrlChanged: (url) {\n    // URL changed\n  },\n);\n```\n\n## Features in Detail\n\n### Ad Blocking\n- Basic support for EasyList and AdGuard filter lists\n- Blocks common ad resources before they load\n- Hides ad elements using CSS rules\n- Supports exception rules for whitelisting\n\n### Resource Blocking\n- Blocks common trackers and unwanted resources\n- Early blocking for better performance\n- Basic domain-based filtering\n- Exception handling for whitelisted domains\n\n### Element Hiding\n- Hides common ad containers and placeholders\n- CSS-based element hiding\n- Basic domain-specific rules support\n- Batch processing for better performance\n\n## Migration Guide\n\n### Migrating from 1.2.0 to 2.0.0-beta\n\n#### Breaking Changes\n\n1. **Controller Initialization**\n   ```dart\n   // Old (1.2.0)\n   final controller = AdBlockerWebviewController();\n   await controller.initialize();\n\n   // New (2.0.0-beta)\n   await AdBlockerWebviewController.instance.initialize(\n     FilterConfig(\n       filterTypes: [FilterType.easyList, FilterType.adGuard],\n     ),\n   );\n   ```\n\n2. **URL Parameter Type**\n   ```dart\n   // Old (1.2.0)\n   AdBlockerWebview(\n     url: \"https://example.com\",\n     // ...\n   )\n\n   // New (2.0.0-beta)\n   AdBlockerWebview(\n     url: Uri.parse(\"https://example.com\"),\n     // ...\n   )\n   ```\n\n3. **Filter Configuration**\n   ```dart\n   // Old (1.2.0)\n   AdBlockerWebview(\n   //.. other params\n     additionalHostsToBlock: ['ads.example.com'],\n   );\n\n   // New (2.0.0-beta)\n   // Use FilterConfig for configuration\n   await AdBlockerWebviewController.instance.initialize(\n     FilterConfig(\n       filterTypes: [FilterType.easyList, FilterType.adGuard],\n     ),\n   );\n   ```\n\n4. **Event Handlers**\n   ```dart\n   // Old (1.2.0)\n   onTitleChanged: (title) { ... }\n\n   // New (2.0.0-beta)\n   // Use onUrlChanged instead\n   onUrlChanged: (url) { ... }\n   ```\n\n#### Deprecated Features\n- `additionalHostsToBlock` parameter is removed\n- Individual controller instances are replaced with singleton\n- `onTitleChanged` callback is replaced with `onUrlChanged`\n\n#### New Features\n- Singleton controller pattern for better resource management\n- Structured filter configuration using `FilterConfig`\n- Improved type safety with `Uri` for URLs\n- Enhanced filter list parsing and management\n- Better performance through early resource blocking\n\n#### Steps to Migrate\n1. Update the package version in `pubspec.yaml`:\n   ```yaml\n   dependencies:\n     adblocker_webview: ^2.0.0-beta\n   ```\n\n2. Replace controller initialization with singleton pattern\n3. Update URL parameters to use `Uri` instead of `String`\n4. Replace deprecated callbacks with new ones\n5. Update filter configuration to use `FilterConfig`\n6. Test the application thoroughly after migration\n\n## Contributing\n\nWe welcome contributions to improve the ad-blocking capabilities! Here's how you can help:\n\n### Getting Started\n1. Fork the repository\n2. Create a new branch from `main` for your feature/fix\n   - Use `feature/` prefix for new features\n   - Use `fix/` prefix for bug fixes\n   - Use `docs/` prefix for documentation changes\n3. Make your changes\n4. Write/update tests if needed\n5. Update documentation if needed\n6. Run tests and ensure they pass\n7. Submit a pull request\n\n### Before Submitting\n- Check that your code follows our style guide (see analysis badge)\n- Write clear commit messages\n- Include tests for new features\n- Update documentation if needed\n- Verify all tests pass\n\n### Pull Request Process\n1. Create an issue first to discuss major changes\n2. Update the README.md if needed\n3. Update the CHANGELOG.md following semantic versioning\n4. The PR will be reviewed by maintainers\n5. Once approved, it will be merged\n\n### Code Style\n- Follow [Effective Dart](https://dart.dev/guides/language/effective-dart) guidelines\n- Use the provided analysis options\n- Run `dart format` before committing\n\n## License\n\nThis project is licensed under the BSD-3-Clause License - see the LICENSE file for details.\n","funding_links":["https://buymeacoffee.com/islamdidarmd"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fislamdidarmd%2Fflutter_adblocker_webview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fislamdidarmd%2Fflutter_adblocker_webview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fislamdidarmd%2Fflutter_adblocker_webview/lists"}