Skip to content

Commit d396aa5

Browse files
committed
Improve desktop webview handling for Windows
1 parent 98a78ce commit d396aa5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/ui/webview_page.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ class _WebviewState extends ConsumerState<Webview> {
4646
@override
4747
void initState() {
4848
super.initState();
49-
// On Linux, use desktop_webview_window
50-
if (PlatformUtils.isLinux) {
49+
// On Linux and Windows, use desktop_webview_window
50+
// On Windows, this avoids "Graphics Context is not valid" (InAppWebView) issues in some environments (Wine/VMs)
51+
if (PlatformUtils.isLinux || PlatformUtils.isWindows) {
5152
WidgetsBinding.instance.addPostFrameCallback((_) {
5253
_openDesktopWebview();
5354
});
@@ -56,7 +57,7 @@ class _WebviewState extends ConsumerState<Webview> {
5657

5758
Future<void> _openDesktopWebview() async {
5859
try {
59-
_logger.info("Opening desktop webview for Linux",
60+
_logger.info("Opening desktop webview for Desktop",
6061
tag: "WebView", metadata: {"url": widget.url});
6162

6263
// Get app documents directory for webview data
@@ -236,8 +237,8 @@ class _WebviewState extends ConsumerState<Webview> {
236237

237238
@override
238239
Widget build(BuildContext context) {
239-
// Show a waiting message for Linux users while desktop webview is open
240-
if (PlatformUtils.isLinux) {
240+
// Show a waiting message for Desktop (Linux/Windows) users while desktop webview is open
241+
if (PlatformUtils.isLinux || PlatformUtils.isWindows) {
241242
return Scaffold(
242243
appBar: AppBar(
243244
automaticallyImplyLeading: true,

0 commit comments

Comments
 (0)