Learn
Web applications
Run the same UseCase in a browser, open the Flutter example, and understand the limits of browser timers and VM diagnostics.
UseCase Forge runs the same Command handlers, instructions, snapshots and lifecycle in a browser. Core 1.5.0 and Flutter companion 1.2.0 have been checked in the configurations below. There is no separate Web UseCase and no browser-specific scheduler to configure.
Choose the right packages
For a Flutter Web application:
flutter pub add usecase_forge:^1.5.0 usecase_forge_flutter:^1.2.0
For a non-Flutter Dart browser application, declare only usecase_forge ^1.5.0. Import the same package:usecase_forge/usecase_forge.dart public library used in Getting started.
Do not copy the internal VM transport or add an initialization call. The compiler selects a browser-safe implementation automatically. Repositories and other dependencies must also support Web: a dart:io file-system adapter cannot be used unchanged in a browser merely because the UseCase compiles.
Open a complete Flutter example
The Flutter repository example contains one application with eight screens. After obtaining that repository, open its example directory and run:
flutter pub get
flutter run -d chrome --target main.dart
Start with Counter. Press +: the widget dispatches a Command, its handler publishes State, and Builder renders the new number. Next try Catalog search for debounce/restart and Ownership for the difference between an owned and externally supplied UseCase. The remaining screens cover effects, several UseCases, cancellation, errors and instance replacement.
The example uses standalone Material for its UI. The Flutter library itself remains independent of Material/Cupertino. Its local parent-package dependency is repository development wiring, not a dependency to copy into your application.
To build optimized JavaScript from the same directory:
flutter build web --target main.dart
Serve build/web over HTTP. Opening source web/index.html or the compiled application through file:// does not start a Flutter application correctly.
Browser validation matrix
The following checks were completed on 4 December 2026, after the package releases. They did not change package versions, dependencies or runtime code. Core was 1.5.0, Flutter and Test 1.2.0, and protocol models 1.3.0.
| Browser and environment | Pure Dart JavaScript | Pure Dart Wasm | Flutter UI |
|---|---|---|---|
| Chromium 151.0.7922.34, Linux ARM64 container | Existing release JS checks remain the baseline | Core 275/275, Test 47/47, protocol 14/14 | JS, real Wasm and forced JS fallback: 8 scenarios + 3 lifecycle contracts per mode |
| Playwright Firefox 153.0, Linux ARM64 container | Core 275/275, Test 47/47, protocol 14/14 | Core 275/275, Test 47/47, protocol 14/14 | JS, real Wasm and forced JS fallback: 8 + 3 per mode; Firefox uses a virtual display |
| Apple Safari 27.2, macOS ARM64 | Core 275/275, Test 47/47, protocol 14/14 | Full pure Dart suites not checked | JS, real Wasm and forced JS fallback: 8 + 3 per mode |
Flutter 3.50.1 and Dart 3.14.0 were used. Chromium was headless; the Flutter Firefox check used Xvfb because headless Firefox in that container had no WebGL and correctly fell back to JavaScript. Playwright Firefox is a patched Linux browser, not proof for every native Firefox version. Safari was the actual Apple browser, not Playwright WebKit.
The eight screens check Counter, search, sign-in navigation, several UseCases, cancellation, ownership variants, error handling and instance replacement. The three instrumented contracts check old Builder subscription cancellation on replacement, preservation of externally owned instances, and a single Owner close during an async operation with no late State or child rebuild. This is not proof of every Listener/Selector race.
A successful Wasm build alone is not a Wasm pass. The validation app checks bool.fromEnvironment('dart.tool.dart2wasm'). Wasm cases must display wasm; fallback uses the Wasm build with Wasm disabled and must display javascript. Every completed UI mode had no observed page errors; expected renderer or fallback warnings are not performance measurements.
The checks do not cover physical mobile devices, background-tab deadlines, a multithreaded renderer or every browser version. DevTools still cannot inspect a Flutter Web application through its VM transport.
Repeat the checks
For a normal application build, from the example directory:
flutter build web --release --wasm --target main.dart
Serve the output over HTTP. The Wasm build also contains a JavaScript fallback. Renderer/browser selection and required features are described in the official Flutter Wasm guide.
For the exact eight-screen checks, compiled backend marker, lifecycle counters and driver commands, use the versioned validation instructions. These tools were committed after v1.2.0: obtain that commit rather than expecting them in the published 1.2.0 archive.
The guide separates container Chromium/Firefox from native Safari. Safari requires temporarily authorized Remote Automation and an unlocked Mac with a visible, focused test window. Restore the original automation setting afterward. Do not install browsers, change security settings or download a different SDK merely to run the normal example.
Browser timers and shutdown
Debounce, throttle and rate limiting keep their defined ordering rules, but a browser can delay timers when a tab is inactive. Do not use these timers as a hard real-time deadline. Controlled-clock tests check policy semantics, not how soon the operating system wakes a suspended tab.
Cancellation remains cooperative: it does not forcibly abort an arbitrary Future. Closing a tab can terminate execution before an asynchronous close() completes. Persist important data as part of the business operation rather than relying on cleanup at tab exit.
Execution events are not a VM connection
The public UseCaseExecutionObserver works in the browser and receives technical events without Command or State values. An execution ID belongs to one UseCase; an aggregator observing several instances must retain the source identity as well.
The DevTools interface also runs in a browser, but it connects to a Dart VM application, not to a Flutter Web target. A Web build does not register the VM bridge or invoke application-value encoders. Installing the DevTools package does not connect the public Observer to that panel.
For package-maintainer commands, see the in-place VM/browser validation guide. Use the DevTools availability guide when diagnosing a missing VM connection.