Im working on Flutter web and I want to render an html code. Since flutter_webview_plugin doesnt support flutter web yet Im using IFrameElement and HtmlElementView. But I have this problem when using dart.ui, platformViewRegistry
method isn't defined.
Error message:
The name 'platformViewRegistry' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix.
import 'dart:ui' as ui;
......
ui.platformViewRegistry.registerViewFactory(
createdViewId,
(int viewId) => html.IFrameElement()
..width = MediaQuery.of(context).size.width.toString() //'800'
..height = MediaQuery.of(context).size.height.toString() //'400'
..srcdoc = """<!DOCTYPE html><html>
<head><title>Page Title</title></head><body><h1>This is a Heading</h1><p>This is a paragraph.</p></body></html>"""
..style.border = 'none');
Example Code From: https://stackoverflow.com/a/60089273/12789200
I read some solution to solve this problem. But I don't want to downgrade my flutter version. Since in the past month Flutter has a lot of changes
Flutter Doctor
[√] Flutter (Channel beta, 1.22.1, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.49.3)
[√] Connected device (3 available)
Is there any other solution for this problem? Or another example I can used for WebView on Flutter Web.