Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: 'WebViewPlatform.instance != null' in Windows application

Tags:

flutter

I am learning the webViewWidget with the codelab, and having trouble using the widget. In particular, how can I handle webViewWidget when targeting the Windows app? The error goes away when using Android Emulator.

It's intuitive since I can implement RWD at the same time. However, reading through the documentation, I don't see the specific settings to resolve the issue.

Here is the code snippet from the codelab:

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(
    const MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: WebViewApp(),
    ),
  );
}

class WebViewApp extends StatefulWidget {
  const WebViewApp({super.key});

  @override
  State<WebViewApp> createState() => _WebViewAppState();
}

class _WebViewAppState extends State<WebViewApp> {
  late final WebViewController controller;

  @override
  void initState() {
    super.initState();
    controller = WebViewController()
      ..loadRequest(
        Uri.parse('https://flutter.dev'),
      ); // error when instantiating the WebViewController in Windows app
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter WebView'),
      ),
      body: WebViewWidget(
        controller: controller,
      ),
    );
  }
}
like image 653
Woden Avatar asked Feb 02 '26 17:02

Woden


1 Answers

error when instantiating the WebViewController in Windows app

...that's because Flutter's webview_flutter doesn't support Windows. The documentation you linked to says it only supports Android and iOS:

enter image description here

like image 144
Dai Avatar answered Feb 05 '26 08:02

Dai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!