Skip to content

feat: WebView on Windows and Linux, built on webview_all for every platform - #7124

Draft
ndonkoHenri wants to merge 13 commits into
flet-1.2from
feat/webview-all-1.1
Draft

ndonkoHenri wants to merge 13 commits into
flet-1.2from
feat/webview-all-1.1

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

flet-webview now uses webview_all on every platform, instead of webview_flutter and webview_flutter_web. WebView gains Windows (Edge WebView2) and Linux (WebKitGTK) support, and its methods and events now work on web for same-origin pages and HTML loaded with load_html().

Closes #6530, closes #5934. Supersedes #6836.

What changed

Dart (flet_webview)

  • One lib/src/webview.dart replaces the three per-platform implementations (mobile/macOS, web, and the Windows/Linux placeholder). Props, events and method names are unchanged.
  • Platform-specific settings live in utils/platform_controller*.dart: Android file access, Linux file-URL access, and disposal (Windows/Linux native views, the web iframe session).
  • All eight webview_all* packages are pinned to exactly 1.5.2. They depend on each other with caret constraints, so every one is pinned.
  • Property updates (prevent_links, event subscriptions, url) go through one ordered path, and every method call waits for the latest one, so a load_request() right after update() sees the new prevent_links.
  • A WebView put in the place of another one gets its own state and native webview: the extension keys it by control id.
  • Workarounds for upstream bugs, each tied to a filed issue:

Python (flet_webview)

  • Methods now work on every platform except:
    • load_file, clear_cache and clear_local_storage raise FletUnsupportedPlatformException on web; the two clear methods would wipe the app's own storage there.
    • scroll_to and scroll_by raise it on macOS.
  • Changing url loads the new URL; load_request() stays for re-loading the same URL and for POST.
  • on_web_resource_error also fires for a url that can't be loaded and for a certificate error, which cancels the load.
  • Setting on_scroll to None unsubscribes.
  • The docstrings list each platform's limits, checked on every platform (see Testing).

Linux client and CI

  • On Linux the plugin links WebKitGTK 4.1 into the whole client. So WebView is in the prebuilt full client only, on Debian 12+ and Ubuntu 22.04+. A new webview_enabled switch in ci.yml, and --WEBVIEW_…-- markers in client/, keep it out of older distros and out of the light client.
  • flet-build-test*.yml install libwebkit2gtk-4.1-dev, because the test app includes flet-webview.
  • flet-desktop's startup hint for a client that can't load a library now names libwebkit2gtk-4.1-0.

Docs

  • New Linux system libraries page, the one place for the packages each extension needs to build and run on Linux. It has per-distro commands for the full client, and explains what a missing library looks like.
  • Installation, Video, Audio, WebView, flet pack and publish/linux now link to it instead of repeating package lists.
  • WebView page: Windows, Linux and web requirements.

Breaking changes

All three are in the 1.2.0 changelog.

  • The full Linux desktop client needs libwebkit2gtk-4.1-0 to start, even for apps that don't use WebView. The default light client doesn't.
  • flet build linux of an app that includes flet-webview needs libwebkit2gtk-4.1-dev to build and libwebkit2gtk-4.1-0 to run. So such apps don't run before Debian 12 / Ubuntu 22.04, even if they show the WebView only on other platforms.
  • scroll_to() and scroll_by() raise FletUnsupportedPlatformException on macOS, which doesn't support them.

Testing

A harness that exercises all 19 methods and 8 events, plus per-claim probes for every docstring note, on webview_all 1.5.2:

Platform Pass / fail / info
macOS client, and a macOS release build with flet-ads 30 / 0 / 3
iOS simulator with flet-ads 30 / 0 / 3
Android emulator with flet-ads 30 / 0 / 3
Ubuntu 24.04, Wayland and XWayland 30 / 0 / 3
Windows 11 29 / 1 / 3
Web, skwasm 28 / 2 / 2
Web, canvaskit 22 / 8 / 2
  • Windows: the one failure is [windows] loadRequest with LoadRequestMethod.post and no body fails with WebErrorStatusUnexpectedError abandoft/webview_all#59, a POST without a body.
  • Web, skwasm: the two failures are the browser's cross-origin limits.
  • Web, canvaskit: the six extra failures are [web] With a scroll handler, dart2js builds never fire onPageFinished for cross-origin pages abandoft/webview_all#55. While on_scroll is set, cross-origin pages never fire on_page_ended; unsubscribing ends it. It's documented in the on_scroll, on_page_ended and on_progress notes.
  • Review fixes: after a Codex review, a probe covering WebView swaps, prevent_links ordering, url changes, bad URLs, certificate errors, scroll unsubscribe and calls on a removed WebView passes on every platform above, and the harness results stay as in the table. On web, removing a WebView now releases its window listeners right away (checked over CDP across 20 add/remove cycles).
  • flet-ads coexistence: its webview_flutter and webview_all coexist on Android, iOS and macOS.
  • Linux clients: both flavors were built with the CI step unchanged.
    • The full client links WebKitGTK and renders pages.
    • The light client has no WebKit, and starts without it.
    • Without WebKitGTK, the full client exits with 127, and the new hint is printed.
  • Package names: every one in the docs and the hint was checked on Debian 11/12, Ubuntu 20.04/22.04/24.04, Fedora 44, openSUSE Tumbleweed and Rocky 9.

Other upstream issues found along the way: abandoft/webview_all#56, #57 and #58.

Summary by Sourcery

Expand flet-webview to Windows and Linux while standardizing its cross-platform implementation and documenting the resulting platform requirements and limitations.

New Features:

  • Add WebView support for Windows and Linux, and enable supported methods and events on web for same-origin content and HTML loaded with load_html().
  • Unify WebView implementations across platforms on the webview_all package.

Bug Fixes:

  • Improve WebView initialization, navigation, local-file loading, event handling, and resource cleanup across supported platforms.

Enhancements:

  • Add platform-specific WebView behavior and explicit unsupported-platform handling for methods with platform limitations.
  • Separate Linux full and light client builds so WebKitGTK is included only where WebView support is enabled.

Build:

  • Pin the webview_all package set to version 1.5.2 and add WebKitGTK build dependencies where required.

CI:

  • Update Linux CI matrices and build tests to conditionally install WebKitGTK and validate WebView-enabled clients.

Deployment:

  • Update Linux client runtime guidance and startup diagnostics for the WebKitGTK dependency.

Documentation:

  • Document WebView requirements and platform limitations, and add a centralized Linux system libraries reference covering build and runtime dependencies.

Tests:

  • Expand platform coverage and WebView validation across desktop, mobile, and web targets.

Chores:

  • Record the new WebView capabilities and Linux dependency requirements in the 1.2.0 changelogs.

`flet-webview` now uses the `webview_all` Flutter package family on Android,
iOS, macOS, Windows, Linux and web, instead of `webview_flutter` and
`webview_flutter_web`. Windows (Edge WebView2) and Linux (WebKitGTK) get a
working WebView, and on web the methods and events work for same-origin pages
and HTML loaded with `load_html()` instead of only showing the initial `url`.

The four platform-split Dart implementations collapse into one, on the
app-facing `webview_all` WebViewController. The platform extras (Android file
access, Linux file-URL creation params, Windows/Linux controller disposal) sit
behind a `dart.library.io` conditional import, which unlike the previous
`dart.library.html` key also holds under dart2wasm.

All eight `webview_all` packages are pinned exactly, to 1.4.4: they depend on each other
with caret constraints, so pinning the umbrella alone would let the rest float.
1.4.0 is the oldest release that can share an app with the `webview_flutter`
that `google_mobile_ads` (flet-ads) pulls in; earlier ones registered the same
platform view type and channel names. Both stacks are linked side by side in
the client on Android, iOS and macOS.

Behaviour details:
- Initialization is serialized (delegate, subscribed handlers, JavaScript
  mode, initial load), because Windows and WKWebView install the console and
  scroll bridges as scripts that only reach later documents. Invoked methods
  wait for it, and a failed initial load (e.g. a `url` without a scheme) is
  logged rather than failing every later method call.
- `onNavigationRequest` is only registered while `prevent_links` is not empty:
  on Windows an intercepted navigation is cancelled and started again as a
  GET, which drops a submitted form's body.
- The alert handler stays lazy, since setting it suppresses the built-in
  dialog on Android, WebKitGTK and web.
- WKWebView's zoom state is synced at init on macOS, where the controller
  assumes zoom is on while magnification starts off.
- `bgcolor` is applied once per change and never throws inside `build()`; the
  previous macOS implementation threw synchronously there.

Python: every method used to be rejected on web, Windows and Linux. Now only
what cannot work is rejected: `load_file`, `clear_cache` and
`clear_local_storage` on web (the last two would clear the Flet app's own
storage there) and `scroll_to`/`scroll_by` on macOS. The docstrings describe
the per-platform limits.

Linux: `webview_all_linux` links webkit2gtk-4.1 into the whole binary, and
that library is absent before Debian 12 / Ubuntu 22.04. `flet_webview` is
therefore gated in the client behind `--WEBVIEW_*--` markers and a
`webview_enabled` CI matrix flag, and kept out of the light flavor. The
build-test workflows install `libwebkit2gtk-4.1-dev`. It is not added to
flet-cli's `linux_dependencies`, which is published as a copy-paste apt
one-liner and has to stay installable on older distributions.

Checked with an automated harness covering the 19 methods, 8 events,
`prevent_links`, `bgcolor`, `url=file://`, re-creation and a bad initial
`url`: macOS client 34/34, iOS simulator `flet build` with flet-ads 34/34, and
web (wasm) client 31/33, where both misses are the documented limit on links
followed to another origin. Android, Windows and Linux were not run.
…se builds

On iOS and macOS, webview_all keeps the setOnConsoleMessage handler only
in JavaScriptChannelParams.onMessageReceived, and the native script
message handler reaches it through a weak reference. No code reads that
field, so the AOT compiler drops it as write-only in release builds, the
handler is garbage collected and console messages stop after the next
collection. Reading the field once when the handler is registered keeps
it (verified in a macOS release build: 29/30 before, 30/30 after).

Also document that on Android scroll positions and amounts are physical
pixels and that console.info() arrives with the LOG severity level.
webview_all_windows 1.4.4 serves loadFile() from a WebView2 virtual host
mapped to the file's folder, and Set/ClearVirtualHostNameMapping return
the WebView2 HRESULT from a bool function, so every successful removal
of the mapping is reported as a failure. After any loadFile(), every
loadRequest(), loadHtmlString() and loadFile() of another folder threw
PlatformException(method_failed) until the WebView was disposed.

On Windows, load_file and url=file:// now navigate to the file's
file:/// URL instead, which needs no mapping; WebView2 resolves the
page's sibling files relative to it. The page gets a file: origin, so
fetch, XHR and JavaScript modules can't read local files from it (they
could under the virtual host); the docstring says so. Verified on
Windows 11 with WebView2 154: the load-file probes went from 14 failures
to none, and get_current_url now reports the file:/// URL.
…e Linux requirement

- load_request(): on Windows a POST request fails, because
  webview_all_windows 1.4.4 sends it without a body.
- on_progress: in web apps compiled to JavaScript, while on_scroll is
  set, a cross-origin page reports only 0 (dart2js strips webview_all_web's
  cross-origin probe, so the scroll listener throws before progress 100).
- CHANGELOG: list the full Linux client's new libwebkit2gtk-4.1-0
  requirement under breaking changes, and add the Linux run/build
  requirements to the flet-webview changelog.
Pins all eight webview_all packages (the umbrella, the six platform
implementations and webview_platform_interface) to exactly 1.5.2, and
updates client/pubspec.lock to match. They depend on each other with
caret constraints, so every package stays pinned to keep the set on one
release.

Upstream fixes picked up since 1.4.4 include scroll callbacks that
stopped after a page rewrote its document (Linux, Windows, web), Windows
loadHtmlString reporting success when the load failed, and Windows
session cookies disappearing before the first page load. 1.5.0 requires
iOS 14 and macOS 11; the client targets iOS 15 and macOS 12.

No Dart changes were needed: `flutter analyze` on flet_webview reports
no issues, and the macOS debug client builds.
Removes the private `_check_platform_support()` helper. The methods that
are not supported everywhere now raise `FletUnsupportedPlatformException`
in their own body, as other extensions such as flet-geolocator do:

- `load_file()`, `clear_cache()` and `clear_local_storage()` on web;
- `scroll_to()` and `scroll_by()` on macOS desktop. A web app opened in
  a browser on a Mac reports the macOS platform too, so the check
  excludes web, where scrolling works.

The other methods no longer check anything before calling
`_invoke_method()`, which already raises when the control has not been
added to a page. Behavior is unchanged.
The class docstring's Note held the Windows, Linux and web requirements
and limits as three paragraphs. They are now one bullet per point: the
Windows runtime, the Linux library, the Linux native-widget limits, the
web iframe embedding limits, and the web cross-origin limits.
…ted packages

Adds website/docs/reference/linux-system-libraries.md (Reference sidebar) as
the single place for the system packages Linux apps need:
- what to install for each case: light client, full client, `flet build
  linux`, shipping a built app;
- a table by extension (every app, flet-secure-storage, flet-audio,
  flet-video, flet-webview, flet-rive) with the desktop client flavor, the
  runtime and build packages, and the oldest distribution;
- the full desktop client's install command per distribution: Debian 12+ /
  Ubuntu 24.04+, Ubuntu 22.04, Debian 11 / Ubuntu 20.04, Fedora, openSUSE
  Tumbleweed, Rocky/AlmaLinux 9 (EPEL + CRB);
- what a missing library looks like: exit 127 and the loader error, before
  any app code runs.

The installation, Video, Audio, WebView, flet pack and publish/linux pages
now link to it instead of repeating package lists. publish/linux's two
"won't start" troubleshooting rows become one, its .deb and .rpm recipes
point to the runtime packages per extension, and FLET_LINUX_DISTRO's table
lists libwebkit2gtk-4.1.so.0 for the builds that load it. The flet pack page
lists WebView among the extensions the light client leaves out.

flet-desktop's startup hint for a client that exits with 127 now names
WebKitGTK and `libwebkit2gtk-4.1-0` for the full client, and links to the
new page.

CHANGELOG 1.2.0 gains two breaking changes (flet build linux apps including
flet-webview need WebKitGTK; WebView.scroll_to/scroll_by raise on macOS) and
a Documentation entry.

The package names and the missing-library behavior were checked in Debian
11/12, Ubuntu 20.04/22.04/24.04, Fedora 44, openSUSE Tumbleweed and Rocky 9,
with full and light clients built as CI builds them. The docs build passes.
…5.2 retest

The harness and per-claim probes were re-run on webview_all 1.5.2 on macOS
(client and release build), iOS simulator, Android, web (JS and wasm),
Ubuntu 24.04 (Wayland and XWayland) and Windows 11. The notes that no longer
match are updated:

- Linux clips: rectangular clips and a Card's rounded corners apply to the
  WebView; other clips, such as a Container with border_radius or a circular
  shape, still hide it.
- Linux load_request POST: it now carries the WebView's cookies and keeps
  the ones its response sets; a failed request still raises instead of
  firing on_web_resource_error.
- on_scroll: a handler set after mount fires on the current page on Windows,
  and on web it fires for same-origin pages and HTML loaded with load_html,
  not only the first page.
- With the canvaskit web renderer (the default for static web apps, and
  what `auto` picks outside Chromium), setting on_scroll keeps on_page_ended
  from firing for cross-origin pages and POST responses (reported upstream
  as abandoft/webview_all#55). on_scroll, on_page_ended and on_progress say
  so.
- on_url_change, get_current_url and reload on web: after a link to another
  origin they use the last URL the WebView could read.
@ndonkoHenri ndonkoHenri added this to the 1.2.0 milestone Nov 23, 2026
Adds the PR link to the 1.2.0 entries for the webview_all migration, in CHANGELOG.md and in the flet-webview package changelog, next to the issue links.
@ndonkoHenri
ndonkoHenri removed the request for review from FeodorFitsner November 23, 2026 00:38
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7579244
Status: ✅  Deploy successful!
Preview URL: https://cd591469.flet-website-v2.pages.dev
Branch Preview URL: https://feat-webview-all-1-1.flet-website-v2.pages.dev

View logs

…url updates

From a Codex review of PR #7124, each finding checked against the code and
the webview_all 1.5.2 sources:

- A WebView put in the place of another one gets its own state and native
  webview: the extension keys it by control id (or the user's key). Before,
  Flutter reused the old state, so the replacement never loaded and its
  method calls timed out.
- Property updates (prevent_links, event subscriptions, url) run in order
  through one path, and every method call waits for the latest one, so a
  load_request right after update() sees the new prevent_links.
- prevent_links is also checked for loads the app starts (load_request,
  url): Android's loadUrl skips the navigation delegate.
- Changing `url` loads the new URL.
- A `url` that can't be loaded, and a certificate error, fire
  on_web_resource_error; a certificate error also cancels the load.
- Setting on_scroll to None unsubscribes (setOnScrollPositionChange(null)),
  which also ends the canvaskit page_ended loss of
  abandoft/webview_all#55 for that WebView.
- On web, removing a WebView closes its iframe session
  (closeWebViewSession) instead of leaving it to garbage collection.
- A method call that resumes after the WebView was removed raises instead
  of using a disposed controller.
- The initial load no longer reads a `method` property, which Python never
  sends.

Docstrings of `url` and `on_web_resource_error` describe the new behavior;
both changelogs list it, and the main feature entry is shorter.

Tested with a probe for these fixes (review_fixes.py) and the full harness
on the macOS client, iOS simulator, Android emulator, Ubuntu 24.04 Wayland,
Windows 11 and web (canvaskit and skwasm): every probe check passes, and the
harness matches its pre-fix baseline on each platform.
The Rocky Linux and AlmaLinux 9 tab of the Linux system libraries page
said to build the client locally against the installed libraries, which
fails for a WebView app: these releases ship only WebKitGTK 4.0. The local
build advice is now for audio and video, and a separate sentence says
WebView isn't available there.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant