I am getting the following error when I try to run the url using Webview on Flutter web:
WebViewPlatform.instance != null
“A platform implementation for webview_flutter
has not been set. Please ensure that an
implementation of WebViewPlatform
has been set to WebViewPlatform.instance
before use. For unit
testing, WebViewPlatform.instance
can be set with your own test implementation.”
Here is the code snippet:
class CheckoutPage extends StatefulWidget {
const CheckoutPage({super.key, required this.url});
final String url;
@override
State<CheckoutPage> createState() => _CheckoutPageState();
}
class _CheckoutPageState extends State<CheckoutPage> {
WebViewController controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted);
@override
Widget build(BuildContext context) {
controller.loadRequest(Uri.parse(widget.url));
return Scaffold(body: WebViewWidget(controller: controller));
}
}
I am running on Flutter web and what is the fix?