{
    "url": "https://delaparra-services.nl/skills/flutter-web",
    "locale": "en",
    "title": "Flutter Web | DeLaParra Services",
    "description": "Use when working on a Flutter web build - code touching dart:js_interop, package:web or dart:ui_web; tests that will not compile on the VM runner; a blank white page after a build; or QA of a running web app in a browser. Triggers on \"works on mobile but not on web\", a suite that breaks after a web import is added, or a screen that looks frozen in the browser.",
    "alternates": {
        "en": "https://delaparra-services.nl/skills/flutter-web",
        "nl": "https://delaparra-services.nl/nl/skills/flutter-web"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/skills/flutter-web.csv",
        "md": "https://delaparra-services.nl/skills/flutter-web.md",
        "json": "https://delaparra-services.nl/skills/flutter-web.json",
        "zip": "https://delaparra-services.nl/skills/flutter-web.zip",
        "pdf": "https://delaparra-services.nl/skills/flutter-web.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/skills/flutter-web.csv",
            "encodingFormat": "text/csv",
            "name": "flutter-web.csv"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-web.json",
            "encodingFormat": "application/json",
            "name": "flutter-web.json"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-web.md",
            "encodingFormat": "text/markdown",
            "name": "flutter-web.md"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-web.pdf",
            "encodingFormat": "application/pdf",
            "name": "flutter-web.pdf"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-web.zip",
            "encodingFormat": "application/zip",
            "name": "flutter-web.zip"
        },
        {
            "url": "https://delaparra-services.nl/skills/flutter-web/download",
            "encodingFormat": "application/zip",
            "name": "flutter-web-files.zip"
        }
    ],
    "markdown": "# Flutter Web\n\n \n\nUse when working on a Flutter web build - code touching dart:js\\_interop, package:web or dart:ui\\_web; tests that will not compile on the VM runner; a blank white page after a build; or QA of a running web app in a browser. Triggers on \"works on mobile but not on web\", a suite that breaks after a web import is added, or a screen that looks frozen in the browser.\n\n \n\n**Licence** MIT\n\n \n\n**Source** gabuldev/flutter-skills\n\n [Download zip](<https://delaparra-services.nl/skills/flutter-web/download>)   \n\nYou are working on a Flutter **web** build. Everything here is a lesson that cost real hours — each one looks like an application bug and is not.\n\n \n\n## Browser QA only counts in a visible tab\n\n \n\nFlutter web drives its **entire** frame pipeline from ` requestAnimationFrame `, and Chrome throttles rAF to near zero in a tab that is not the active one. In a background tab the app still runs — events are processed, network calls fire — but it barely paints. So route transitions appear frozen for tens of seconds, and click coordinates read off a screenshot land nowhere, because the painted frame no longer matches the real hit-test layout.\n\n \n\nThat looks exactly like two bugs that do not exist: a slow splash screen and broken Tab traversal.\n\n \n\nBefore blaming the app:\n\n \n\n```\ndocument.visibilityState   // must be \"visible\"\n```\n\n \n\nIf it reports ` hidden `, bring the browser window forward and make the tab active. Two things stay reliable either way, and are the better evidence:\n\n \n\n- ` performance.getEntriesByType('resource') ` for real timings — in one case it showed auth resolving at 1.4s while the screen looked stuck for 20s. \n- ` document.activeElement `, and the hidden ` <input> ` Flutter creates for the focused text field, which proves where focus actually is.\n\n \n\nEach CDP screenshot forces one frame, so consecutive screenshots step a stalled transition forward — useful, and itself a hint that you are in a throttled tab.\n\n \n\n## Browser-layer code needs the Chrome test runner\n\n \n\nAnything touching ` dart:js_interop ` or ` package:web ` — ` getUserMedia `, ` MediaRecorder `, an ` <audio> ` element — **cannot even compile** under the default VM test runner.\n\n \n\n` @TestOn('browser') ` is what makes that survivable: ` flutter test ` *skips* an annotated file instead of compiling it. The browser layer is untested by default, not untestable:\n\n \n\n```\nflutter test                      # VM: controllers, repositories, pure widgets\nflutter test --platform chrome    # the browser layer\n```\n\n \n\n**Both commands run over ` test/ `.** Do not move browser tests to a directory of their own — the web runner builds its entrypoint with ` test/ ` as the root, so a path outside it becomes a ` ../ ` that does not resolve and nothing compiles at all. The annotation is the separator, not the directory.\n\n \n\nThe trap that makes this dangerous: ` flutter test ` alone reports **green** over a browser test that never compiled. Run both before pushing, and run both in CI as two separate steps.\n\n \n\n` --platform chrome ` is also flaky or unavailable on some machines (a file with ` @TestOn('browser') ` hanging at *loading* until the test timeout is the usual symptom). Where that happens, CI is the only place the browser layer runs — so prefer **pulling the logic out of the browser-bound file into a plain Dart one** and testing that on the VM runner.\n\n \n\n### Make it testable: contract first, js\\_interop behind it\n\n \n\nDeclare the **minimum contract as an abstract class**, keep the ` js_interop ` implementation behind it, and inject it so a widget test can pass a fake:\n\n \n\n```\nabstract class AudioRecorder {\n  Future<void> start();\n  Future<Uint8List?> stop();\n  void dispose();\n}\n\n// browser_audio_recorder.dart — the only file importing package:web\nclass BrowserAudioRecorder implements AudioRecorder { ... }\n```\n\n \n\n### Every exit path must release a browser resource\n\n \n\nWhen a widget holds a browser resource, release it on **every** way out — not only the happy one:\n\n \n\n- ` dispose() ` unconditionally, rather than only when a ` _recording ` flag flipped. \n- A release when the screen turns out to be unmounted after an ` await `. \n- A guard so a second tap during the first ` await ` is a no-op.\n\n \n\nA real leak was exactly the gap between those: permission was still pending, so the flag had not flipped, so ` dispose() ` released nothing — and an orphaned ticker wrote to a closed ` StreamController ` every 200 ms for the life of the tab.\n\n \n\n## Blank white page after changing a path dependency\n\n \n\nPath dependencies (a ` design_system/ ` or ` calendar/ ` package in the same repo) are not always picked up by the incremental web build. It emits a bundle that compiles, loads every asset, throws no JS error — and renders a blank white page with an empty ` <flutter-view> `. Hours disappear looking for a bug in code that is fine.\n\n \n\n```\nrm -rf build/web && flutter build web --release --dart-define=BASE_URL=...\n```\n\n \n\nDo that **before** concluding anything from a blank screen.\n\n \n\n## Watch the import chain, not just the import\n\n \n\nA web-only import poisons every file that reaches it transitively, and the compiler names the file that failed — not the file at fault.\n\n \n\nThe classic shape: a ` app_routes.dart ` holding both the route-name constants *and* the route table. The table imports every screen, one of which imports ` dart:ui_web `. A sign-out use case importing that file for **one string constant** then makes every VM test that touches it fail to compile, taking the whole suite with it.\n\n \n\nThe fix is to split the constants into a file that imports nothing:\n\n \n\n```\n// app_route_names.dart — imports nothing\nclass AppRouteNames {\n  static const login = '/login';\n  static const home  = '/home';\n}\n\n// app_routes.dart — re-exports the names, and owns the table\nexport 'app_route_names.dart';\n\nclass AppRoutes { /* onGenerateRoute + the table */ }\n```\n\n \n\nRe-export at the **library** level, with ` export `. Do not try to inherit the names (` class AppRoutes extends AppRouteNames `): Dart does not inherit static members, so ` AppRoutes.login ` would not resolve even when it compiles — and if the names class is ` final `, extending it is a compile error outright. Callers say ` AppRouteNames.login `; the ` export ` is what saves them a second import.\n\n \n\nScreens and the root widget may import the table. A use case, a repository or an interceptor may not — they take the names file.\n\n \n\nSo when the VM suite fails to **load** a file rather than fail an assertion, read which file it named, then walk the import chain back to the web-only leaf.\n\n \n\n## Checklist before shipping a web change\n\n \n\n```\nflutter analyze\nflutter test                              # VM\nflutter test --platform chrome            # browser layer\nrm -rf build/web\nflutter build web --release --dart-define=BASE_URL=<api-url>\n```\n\n \n\n## Common mistakes\n\n \n\n- Debugging a \"frozen\" screen in a background tab. Check ` document.visibilityState ` first. \n- Trusting a green ` flutter test ` over code that only compiles on the browser runner. \n- Moving browser tests out of ` test/ ` — ` --platform chrome ` cannot resolve a path outside it. \n- Calling ` js_interop ` straight from a widget instead of behind an injectable interface. \n- Releasing a browser resource only on the happy path. Unmount during an ` await ` is a real exit. \n- Concluding \"blank page = my bug\" without a clean ` build/web ` rebuild first. \n- Importing the route *table* from a use case or interceptor just to read one route name. \n- Forgetting ` --dart-define=BASE_URL `, so the compile-time constant is ` \"\" ` and every call fails. See **flutter-run**. \n- Leaving semantics off — Flutter web disables them by default. See **flutter-accessibility**.\n\n \n\n## Files\n\n \n\n- ` LICENSE ` \n- ` SKILL.md ` \n- ` SOURCE.md `\n\n \n\n## Related terms\n\n \n\n- [Flutter Web](<https://delaparra-services.nl/knowledge-hub/flutter-web>)\n\n \n\n## Related services\n\n \n\n- [App development](<https://delaparra-services.nl/services#service-02>) \n- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)\n\n \n\n[Installing an agent skill in Claude Code, Codex, Cursor and Copilot](<https://delaparra-services.nl/manuals/een-skill-installeren-in-je-ai-assistent>)\n\n[HTML version](https://delaparra-services.nl/skills/flutter-web)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "WebPage",
                "@id": "https://delaparra-services.nl/skills/flutter-web#webpage",
                "url": "https://delaparra-services.nl/skills/flutter-web",
                "name": "Flutter Web | DeLaParra Services",
                "description": "Use when working on a Flutter web build - code touching dart:js_interop, package:web or dart:ui_web; tests that will not compile on the VM runner; a blank white page after a build; or QA of a running web app in a browser. Triggers on \"works on mobile but not on web\", a suite that breaks after a web import is added, or a screen that looks frozen in the browser.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/skills/flutter-web#breadcrumb"
                }
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/skills/flutter-web#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Flutter Web"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "SoftwareSourceCode",
                "@id": "https://delaparra-services.nl/skills/flutter-web#skill",
                "url": "https://delaparra-services.nl/skills/flutter-web",
                "name": "Flutter Web",
                "description": "Use when working on a Flutter web build - code touching dart:js_interop, package:web or dart:ui_web; tests that will not compile on the VM runner; a blank white page after a build; or QA of a running web app in a browser. Triggers on \"works on mobile but not on web\", a suite that breaks after a web import is added, or a screen that looks frozen in the browser.",
                "inLanguage": "en",
                "license": "https://spdx.org/licenses/MIT.html",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/skills/flutter-web#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/skills/flutter-web#dataset",
                "name": "Flutter Web",
                "description": "Use when working on a Flutter web build - code touching dart:js_interop, package:web or dart:ui_web; tests that will not compile on the VM runner; a blank white page after a build; or QA of a running web app in a browser. Triggers on \"works on mobile but not on web\", a suite that breaks after a web import is added, or a screen that looks frozen in the browser.",
                "url": "https://delaparra-services.nl/skills/flutter-web",
                "identifier": "https://delaparra-services.nl/skills/flutter-web#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/skills/flutter-web#skill"
                },
                "creditText": "gabuldev/flutter-skills",
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://spdx.org/licenses/MIT.html",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "dateModified": "2026-11-30T13:17:19+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#skills",
                    "name": "Skills for AI coding assistants",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "flutter-web.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-web.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-web.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-web.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-web.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-web.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-web.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-web.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-web.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-web.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "flutter-web-files.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/flutter-web/download",
                        "inLanguage": "en",
                        "dateModified": "2026-11-30T13:17:19+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    }
                ]
            }
        ]
    }
}