Skip to content

Fix the web loading screen being laid out at desktop width on mobile - #6943

Open
ndonkoHenri wants to merge 2 commits into
flet-1.1.0from
fix/web-boot-viewport-6051
Open

ndonkoHenri wants to merge 2 commits into
flet-1.1.0from
fix/web-boot-viewport-6051

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6051

The bug

In a mobile browser, reloading a Flet web app shows the loading logo off-center or not at all until the app starts.

The loading screen is plain HTML in client/web/index.html: a full-screen flex box (position: fixed; inset: 0) that centres the logo. That page has no <meta name="viewport">, so a mobile browser lays it out as a 980 CSS px desktop page. The Flutter engine adds its own viewport tag only when it starts. The order of events is:

  1. First load. Chrome lays the page out at 980 px and zooms out to fit, about 0.42. The logo is centred, but shrunk to about 84 dp instead of 200.
  2. The engine starts. Its tag switches the page to device width at scale 1.0.
  3. Reload. Chrome keeps the 1.0 scale, but the new page is laid out at 980 px again. Only the left 412 px are visible, and the logo, centred at x ≈ 490, is past the right edge. The page stays blank until the engine starts.

This affects everything served by the prebuilt web client: flet run --web, ft.run(view=ft.AppView.WEB_BROWSER), FastAPI hosting and flet publish. Apps built with flet build web are not affected, because the build template's index.html already has the tag.

The fix

Add the same viewport tag that the flet build web template and the Flutter engine use:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

The loading screen is now laid out at device width from the first byte. Once the engine starts, it replaces the tag with its own identical one, so the app behaves exactly as before. Flutter's warning about an existing viewport tag sits in an assert, so it fires only in debug builds.

Testing

Chrome on an Android 14 emulator (412 dp wide). The page was served the way flet run --web serves it, and flutter_bootstrap.js was held back so the loading screen could be measured. I ran it twice and got the same results.

Current client With this change
First load Centred, 84 dp (980 px layout at 0.42 zoom) Centred, 200 dp
3 reloads (two via DevTools, one via Chrome's reload button) Logo off-screen, blank page Centred, 200 dp, exactly mid-screen
After the engine starts App renders, engine tag only Identical

Top row is the current client, bottom row the fix:
image

Summary by Sourcery

Ensure prebuilt Flet web apps render their loading screen correctly on mobile browsers from the initial page load.

Bug Fixes:

  • Add a mobile viewport configuration to the prebuilt web client so loading screens remain correctly sized and centered after browser reloads.

Chores:

  • Document the mobile web loading-screen fix in the changelog.

client/web/index.html had no viewport meta, so until the engine added
its own, a mobile browser laid the loading screen out at 980 px; after
a reload at the engine's 1.0 zoom the centred logo landed outside the
visible area. Add the same viewport tag the engine and the flet build
web template use.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0bce26c
Status: ✅  Deploy successful!
Preview URL: https://61954f17.flet-website-v2.pages.dev
Branch Preview URL: https://fix-web-boot-viewport-6051.flet-website-v2.pages.dev

View logs

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.

bug: After running flet web, when I refreshed the Android phone's browser for the second time to access loading-animation.png, it was not centered

1 participant