webview_all_linux 0.5.2
webview_all_linux: ^0.5.2 copied to clipboard
A Flutter plugin that provides a WebView widget on Linux using WebKitGTK.
webview_all_linux #
webview_all_linux is the Linux implementation used by webview_all.
It embeds WebKitGTK 4.1 into a Flutter Linux app and exposes the same platform-interface surface used by webview_flutter.
What It Provides #
This plugin is intended to make webview_all work on Linux with an API shape close to webview_flutter.
Currently supported:
WebViewWidgetembedding inside Flutter Linux windows- Page loading: URL, local file, Flutter asset, HTML string
- Navigation: back, forward, reload, current URL, title, progress
- Navigation delegate callbacks
- JavaScript execution and JavaScript channels
- Cookie management
- HTTP auth callback
- TLS/SSL error callback
- JavaScript dialog callbacks: alert, confirm, prompt
- Permission request callback for media permissions
- Basic scroll position APIs
- Background color, JavaScript mode, user agent
Integration #
In normal use you do not need to depend on this package directly. Add webview_all and Linux will resolve to webview_all_linux automatically.
dependencies:
webview_all: ^0.9.3
If you are developing this package locally, use a path override in the consuming app:
dependency_overrides:
webview_all_linux:
path: ../webview_all_linux
Linux Requirements #
This plugin depends on WebKitGTK 4.1 and GTK 3 development files.
Typical Ubuntu packages:
sudo apt install libgtk-3-dev libwebkit2gtk-4.1-dev libsoup-3.0-dev
For better video and subtitle support in modern sites, these runtime packages are also recommended:
sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-plugins-ugly
Example #
import 'package:flutter/material.dart';
import 'package:webview_all/webview_all.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(home: WebPage());
}
}
class WebPage extends StatefulWidget {
const WebPage({super.key});
@override
State<WebPage> createState() => _WebPageState();
}
class _WebPageState extends State<WebPage> {
late final WebViewController controller;
@override
void initState() {
super.initState();
controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageStarted: (String url) => debugPrint('Loading $url'),
onPageFinished: (String url) => debugPrint('Finished $url'),
onWebResourceError: (WebResourceError error) {
debugPrint('${error.errorCode}: ${error.description}');
},
),
)
..loadRequest(Uri.parse('https://flutter.dev'));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Linux WebView')),
body: WebViewWidget(controller: controller),
);
}
}
Current Limitations #
loadRequestcurrently supportsGETrequests and custom headers, but not request bodies.- Permission mapping is currently focused on camera and microphone style requests.
- Some advanced platform-specific WebKit behaviors are approximated rather than being exact mobile-platform equivalents.
- Multimedia capability depends heavily on the host Linux system's GStreamer setup.
Common Runtime Messages #
You may see logs like these while developing:
Unable to load from the cursor themeThis usually comes from the desktop environment or cursor theme setup, not from the plugin.WebKit wasn't able to find a WebVTT encoderThis indicates missinggstreamer1.0-plugins-bad; subtitles may be degraded.GStreamer element h264parse not foundThis indicates missing video codec plugins; some video playback may fail.Sticky event misorderingThis is typically a GStreamer/WebKit warning in the media pipeline, not a Flutter API failure by itself.
Notes #
- Linux support is implemented with native GTK overlay embedding.
- This package is designed for desktop Linux and is not intended for mobile Linux targets.
- If your app runs through
flutter runbut the terminal later reportsLost connection to device, verify whether the app window is still alive before treating it as a WebView crash.