dsbridge_flutter
1.2.0, released 2 years ago by an unverified publisher
A Flutter plugin that enables synchronous and asynchronous JavaScript‑Dart communication via a WebView bridge.
What it does
It wraps webview_flutter and adds a JavaScript bridge allowing Dart code to expose functions to JavaScript and call JavaScript functions. Supports sync, async, progress callbacks, namespaces and debug mode.
AI-written summary of version 1.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need tight two‑way interaction between a WebView's JavaScript and Flutter code
- You want to reuse existing dsbridge.js code without rewriting it
- You require progress callbacks or modal dialogs from JavaScript
Skip it when
- You only need to display static web content without native interaction
- You prefer a pure Dart‑only solution without a WebView
Strengths
- Full‑duplex bridge with sync and async calls
- Namespace support for large API sets
- Progress callbacks and built‑in JavaScript dialogs
Weaknesses
- Depends on webview_flutter, so inherits its platform limitations
- Adds extra layer of complexity compared to direct JavaScript injection
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
import 'package:dsbridge_flutter/dsbridge_flutter.dart';
class JsApi extends JavaScriptNamespaceInterface {
@override
void register() {
registerFunction(testSyn);
registerFunction(testAsyn);
}
String testSyn(dynamic msg) => "$msg[syn call]";
void testAsyn(dynamic msg, CompletionHandler handler) => handler.complete("$msg [ asyn call]");
}
void main() async {
final controller = DWebViewController();
controller.addJavaScriptObject(JsApi());
// load your page, then you can call JS functions:
controller.callHandler('addValue', args: [3,4], handler: (ret) => print(ret));
}Alternatives
Packages that do the same job and could replace dsbridge_flutter.
- webview_flutter_android
Android implementation of the webview_flutter plugin providing a WebView widget.
84Compare - webview_flutter_web
WebView widget implementation for Flutter web.
50Compare - webview_all
A cross-platform WebView plugin for Android, iOS, macOS, Windows, Linux, Web, and OpenHarmony.
87Compare - webview_flutter_wkwebview
A Flutter plugin providing a WebView widget based on Apple's WKWebView control.
88Compare
Works with
Packages commonly used together with dsbridge_flutter: ones it builds on, ones built on it, and its own family.