Package selection guidance compiled from public package information, community data, and project usage.
webviewx is a cross-platform webview package that leverages webview_flutter for Android and iOS, and iframe for web, offering a consistent API across platforms. It supports JavaScript interop, enabling seamless communication between Dart and web content. Designed for developers seeking a unified solution to embed web content in Flutter apps with rich functionality and platform compatibility.
Use cases
Embedding web content in mobile apps
Integrating web-based forms or dashboards
Enabling hybrid app development with web components
Supporting dynamic content loading from URLs
Building web-embedded features in Flutter apps
Key features
Cross-platform support (Android, iOS, Web)
JavaScript interop capability
Uses native webview on mobile and iframe on web
Consistent API across platforms
Lightweight and easy integration
Suitable for
Developers building hybrid Flutter apps
Teams needing web content embedding
Projects requiring JS communication with web views
Apps targeting multiple platforms with shared UI logic
Prototyping web-integrated features quickly
Considerations
Web platform uses iframe, which may limit some advanced webview features
Requires careful handling of security when loading external content
Limited customization compared to native webview implementations
May need additional configuration for complex web interactions
Depends on webview_flutter for mobile, which has its own constraints
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
This package has been deprecated
A feature-rich cross-platform webview using webview_flutter for mobile and iframe for web. JS interop-ready.
1. Create a WebViewXController inside your stateful widget
lateWebViewXController webviewController;
2. Add the WebViewX widget inside the build method, and set the onWebViewCreated callback in order to retrieve the controller when the webview is initialized
If you need to add other widgets on top of the webview (e.g. inside a Stack widget), you MUST wrap those widgets with a WebViewAware widget.
This does nothing on mobile, but on web it allows widgets on top to intercept gestures. Otherwise, those widgets may not be clickable and/or the iframe will behave weird (unexpected refresh/reload - this is a well known issue).
Also, if you add widgets on top of the webview, wrap them and then you notice that the iframe still reloads unexpectedly, you should check if there are other widgets that sit on top without being noticed, or try to wrap InkWell, GestureRecognizer or Button widgets to see which one causes the problem.
3. Interact with the controller (run the example app to check out some use cases)
To make the web version (iframe) work as it is, I had to use some of the code from x-frame bypass in order to make a request to a CORS proxy, which removes the headers that block iframe embeddings.
This might seem like a hack, and it really is, but I couldn't find any other way to make the iframe behave similar to the mobile webview (which is some kind of an actual browser, that's why everything works there by default).
About Web navigation
On web, the history navigation stack is built from scratch because I couldn't handle iframe's internal history the right way.
Known issues and TODOs
[ x ] On web, user-agent and headers only work when using SourceType.urlBypass, and they only have effect the first time being used (view/web.dart)
[ x ] On web, it should be possible to send any errors caught when loading an urlBypass to a dart callback, which will then be sent through the onWebResourceError callback, just like on the mobile version (utils/x_frame_options_bypass.dart)
[ x ] On web, it should be possible to add a custom proxy list without the js null-checking mess (utils/x_frame_options_bypass.dart)
[ ? ] Eventually (if possible), most if not all properties from WebSpecificParams and MobileSpecificParams should merge and theese two objects may disappear
[ x ] On mobile, the controller's value's source type becomes out of sync when moving back and forth in history. This happens because the url change is not yet intercepted and set the model accordingly (shouldn't be hard to fix).
[ ] On mobile, the controller's callJsMethod doesnt throw an error if the operation failed. Instead it only shows the error in console.
[ ] Add tests
List open, there may be others
Credits
This package wouldn't be possible without the following:
x-frame-bypass for allowing the iframe to bypass websites' X-Frame-Options: deny/same-origin headers, thus allowing us to load any webpage (just like on mobile)
https://cors.bridged.cc/ for the free CORS proxy
https://api.codetabs.com/ for the free CORS proxy
And last but not least, http://deversoft.ro (the company I work for) for motivating me throughout the development process