Phase 7 · Platform DeliveryModule 46~56 min read

Flutter for Web & Desktop

Adapt Flutter to browser and desktop constraints with URLs, accessibility, windows, shortcuts, files, packaging, and platform-fit decisions.

What you'll learn

Adapt Flutter to browser and desktop constraints with URLs, accessibility, windows, shortcuts, files, packaging, and platform-fit decisions. The lesson turns the APIs into a repeatable engineering workflow instead of a collection of isolated snippets.

By the end of this lesson, you'll be able to:

  • Apply Web rendering in a production-shaped Flutter feature
  • Apply Browser URLs in a production-shaped Flutter feature
  • Apply Desktop interaction in a production-shaped Flutter feature
  • Apply Windows and menus in a production-shaped Flutter feature

Core mental model

Connect each API to the decision it supports. Flutter code stays maintainable when state, ownership, lifecycle, and platform boundaries are explicit.

ConceptWhat it meansDecision rule
Capability matrixAn explicit record of feature support per targetDecide support and fallbacks before promising platform parity
Browser URLShareable web application state represented in the addressUse declarative routes and test refresh, back, forward, and deep entry
Desktop inputMouse, keyboard, shortcuts, windows, and files shape desktop UXAdd platform-appropriate interactions beyond scaling a mobile screen

Professional workflow

Work in small vertical slices and keep behavior observable from the first iteration.

  1. Define the platform-fit capability matrix boundary: user goal, inputs, visible states, ownership, and expected failures.
  2. Build the smallest working vertical slice with typed data and explicit dependencies.
  3. Represent loading, empty, success, and failure behavior where the feature can encounter them.
  4. Verify logic away from the UI, then exercise the rendered behavior at its public boundary.
  5. Inspect lifecycle, accessibility, performance, security, and platform behavior before widening the feature.
  6. Refactor only after behavior is protected by repeatable evidence.

Protect the frame

Keep build methods predictable, move side effects to explicit owners, and measure before introducing caches, isolates, or architectural layers.

Guided Flutter lab

Build a focused platform-fit capability matrix slice

This compact example keeps the important ownership and data-flow decisions visible so the behavior is easy to extend and test.

lib/platform/capabilities.dart
enum Capability { camera, localFiles, backgroundSync, multiWindow }

Set<Capability> capabilitiesFor(TargetPlatform platform, {required bool web}) {
  if (web) return {Capability.camera, Capability.localFiles};
  return switch (platform) {
    TargetPlatform.android || TargetPlatform.iOS => {
      Capability.camera, Capability.localFiles, Capability.backgroundSync,
    },
    TargetPlatform.windows || TargetPlatform.macOS || TargetPlatform.linux => {
      Capability.localFiles, Capability.multiWindow,
    },
    _ => <Capability>{},
  };
}

Production practice

Contract

Define the platform-fit capability matrix inputs, outputs, owner, lifecycle, visible states, and platform assumptions before selecting APIs or packages.

Verification

Protect pure rules with unit tests and the rendered public contract with widget or integration evidence; include one unavailable or failure case.

Operations

Keep dependencies replaceable, log actionable context without user secrets, and measure user-visible behavior before optimizing.

Common failure mode

Calling a platform 'supported' because the app launches ignores input conventions, deep links, file behavior, accessibility, packaging, and unsupported plugins.

Independent workshop

Extend the guided lab into a review-ready platform-fit capability matrix feature that fits the running course portfolio app.

Your finished workshop must include:

  • Web rendering
  • Browser URLs
  • Desktop interaction
  • Windows and menus
  • Packaging
  • Automated verification and a short design note

Definition of done

Demonstrate the happy path, an empty or unavailable state, and at least one failure path. Add an automated check and a short note explaining one design decision.

Recap & quick check

Key takeaways

  • Capability matrix: Decide support and fallbacks before promising platform parity
  • Browser URL: Use declarative routes and test refresh, back, forward, and deep entry
  • Desktop input: Add platform-appropriate interactions beyond scaling a mobile screen

Quick check

1. Which rule best applies to Capability matrix?

2. Which rule best applies to Browser URL?

3. Which rule best applies to Desktop input?

Next: CI/CD & Team Workflow