{"id":19969424,"url":"https://github.com/epoll-j/bridge_webview_flutter","last_synced_at":"2025-05-04T01:30:31.805Z","repository":{"id":56826731,"uuid":"255865809","full_name":"epoll-j/bridge_webview_flutter","owner":"epoll-j","description":"Add jsbridge to the webview","archived":false,"fork":false,"pushed_at":"2020-10-10T06:37:29.000Z","size":159,"stargazers_count":7,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T00:18:48.629Z","etag":null,"topics":["flutter","flutter-plugin","jsbridge-webview","webview","webview-library"],"latest_commit_sha":null,"homepage":"","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/epoll-j.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-15T09:20:02.000Z","updated_at":"2025-02-05T13:35:04.000Z","dependencies_parsed_at":"2022-09-13T08:12:21.801Z","dependency_job_id":null,"html_url":"https://github.com/epoll-j/bridge_webview_flutter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoll-j%2Fbridge_webview_flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoll-j%2Fbridge_webview_flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoll-j%2Fbridge_webview_flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoll-j%2Fbridge_webview_flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epoll-j","download_url":"https://codeload.github.com/epoll-j/bridge_webview_flutter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252276955,"owners_count":21722447,"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":["flutter","flutter-plugin","jsbridge-webview","webview","webview-library"],"created_at":"2024-11-13T02:50:03.125Z","updated_at":"2025-05-04T01:30:30.969Z","avatar_url":"https://github.com/epoll-j.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"这个库不再维护了，因为跟webview耦合度太高了，把jsbridge内容分离出来重写了一个[plugin](https://github.com/epoll-j/flutter_jsbridge_plugin)\n# Add JsBridge to the WebView\n\n[A Flutter plugin that provides a JsBridge on WebView widget.](https://pub.dev/packages/bridge_webview_flutter)\n\nOn iOS the WebView widget is backed by a [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview);\nOn Android the WebView widget is backed by a [WebView](https://developer.android.com/reference/android/webkit/WebView).\n\nThis plugin based on the [webview_flutter](https://pub.dev/packages/webview_flutter)\n\n## Developers Preview Status\n\nTo use this plugin on iOS you need to opt-in for the embedded views preview by\nadding a boolean property to the app's `Info.plist` file, with the key `io.flutter.embedded_views_preview`\nand the value `YES`.\n\n## Keyboard support - not ready for production use\nKeyboard support within webviews is experimental. The Android version relies on some low-level knobs that have not been well tested\non a broad spectrum of devices yet, and therefore **it is not recommended to rely on webview keyboard in production apps yet**.\nSee the [webview-keyboard](https://github.com/flutter/flutter/issues?q=is%3Aopen+is%3Aissue+label%3A%22p%3A+webview-keyboard%22) for known issues with keyboard input.\n\n## Setup\n\n### iOS\nOpt-in to the embedded views preview by adding a boolean property to the app's `Info.plist` file\nwith the key `io.flutter.embedded_views_preview` and the value `YES`.\n\n## Usage\nAdd `bridge_webview_flutter` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).\n\n```\nBridgeWebView(\n    initialUrl: 'https://flutter.dev',\n    javascriptMode: JavascriptMode.unrestricted,\n    onWebViewCreated: (WebViewController webViewController) {\n        _controller.complete(webViewController);\n        webViewController.registerHandler(\"methodName\", response: \"r1\", onCallBack: (callBackData) {\n            print(callBackData.name); // handler name\n            print(callBackData.data); // callback data ({'param': '1'})\n        });\n        webViewController.callHandler(\"methodName\", data: \"sendData\", onCallBack: (callBackData) {\n            print(callBackData.name); // handler name\n            print(callBackData.data); // callback data (r2)\n        });\n    },\n    onPageStarted: (String url) {\n        print('Page started loading: $url');\n    },\n    onPageFinished: (String url) {\n        print('Page finished loading: $url');\n    }\n)\n```\n\n### Register a Flutter handler function so that js can call\n```\nonWebViewCreated: (WebViewController webViewController) {\n    _controller.complete(webViewController);\n    webViewController.registerHandler(\"methodName\", response: \"r1\", onCallBack: (callBackData) {\n        print(callBackData.name); // handler name\n        print(callBackData.data); // callback data ({'param': '1'})\n    });\n}\n```\n#### js can call this handler method \"methodName\" through:\n```\nWebViewJavascriptBridge.callHandler(\n    'methodName'\n    , {'param': '1'}\n    , function(data) {\n        // data is r1\n    }\n);\n```\n\n### Register a JavaScript handler function so that flutter can call\n```\nWebViewJavascriptBridge.registerHandler(\"methodName\", function(data, responseCallback) {\n    // data is 'sendData'\n    responseCallback('r2');\n});\n```\n#### flutter can call this js handler function \"methodName\" through:\n```\nonWebViewCreated: (WebViewController webViewController) {\n    _controller.complete(webViewController);\n    webViewController.callHandler(\"methodName\", data: \"sendData\", onCallBack: (callBackData) {\n        print(callBackData.name); // handler name\n        print(callBackData.data); // callback data (r2)\n    });\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepoll-j%2Fbridge_webview_flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepoll-j%2Fbridge_webview_flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepoll-j%2Fbridge_webview_flutter/lists"}