-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is there an existing feature request for this?
- I have searched the existing feature request
Operating System
All platforms if possible: Android, iOS, macOS, Windows, Linux, Web (same-origin constraints on Web).
Pain
Current JavaScript communication APIs are powerful, but common app flows still require repetitive low-level code:
- Dart -> JS push-style messaging is usually done with manual
evaluateJavascript. - JS handler payloads often require manual JSON parsing/encoding in app code.
- Event-style communication patterns are not standardized at the controller API level.
- Cross-platform app code becomes verbose and easier to break with custom bridge boilerplate.
This increases complexity for users who need structured, bidirectional JS communication.
Suggested solution
Add an additive high-level JS bridge layer without changing existing behavior:
controller.bridgeEventsAPI
on(eventName, callback)off(eventName, [callback])emit(eventName, data)hasListener(eventName)
- Typed handler helper APIs
addSerializedJavaScriptHandler<TRequest, TResponse>(...)addJsonJavaScriptHandler<TRequest, TResponse>(...)
Design constraints:
- No breaking changes to existing
addJavaScriptHandlerbehavior. - Keep existing bridge security model and allowlist behavior unchanged.
- Do not hardcode bridge global name; use runtime bridge name.
- Implement for all active platform bridge initialization paths to keep API consistency.
Acceptance criteria:
- Existing apps continue to work unchanged.
- New APIs are fully additive.
- Example + integration tests cover bridgeEvents and typed handler roundtrip.
Useful resources
- JS communication docs:
- User scripts docs:
- Content worlds docs:
- JS injection docs:
- API docs:
- Reference design direction:
Additional information
I can implement this in a feature branch and open a PR with:
- platform-consistent bridge wiring
- backward-compatibility checks
- example coverage
- integration tests
Self grab
- I'm ready to work on this issue!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request