---
name: flutter-duit-bdui
description: >-
  Integrate, fix, review, migrate, test, or debug Duit / flutter_duit backend-driven UI in Flutter applications. Use when a task mentions DUIT, flutter_duit, backend-driven UI, BDUI, server-driven UI, XDriver, DuitViewHost, DuitRegistry, HTTP or WebSocket transports, custom Duit widgets, components, capability delegates, compile-time DUIT flags, or rendering JSON layouts from a backend.
title: flutter-duit-bdui
canonical_url: https://skilld.dev/gh/madteacher/mad-agents-skills/flutter-duit-bdui
last_updated: 2026-10-08T16:01:54.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/capabilities.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-duit-bdui/references/capabilities.md), [references/environment_vars.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-duit-bdui/references/environment_vars.md), [references/public_api.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-duit-bdui/references/public_api.md), [references/troubleshooting.md](https://skilld.dev/api/skills-raw/madteacher/mad-agents-skills/flutter-duit-bdui/references/troubleshooting.md).
>
> If the user asked to install this Skill, run `npx skilld install madteacher/mad-agents-skills/flutter-duit-bdui`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/flutter-duit-bdui`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/madteacher/mad-agents-skills/flutter-duit-bdui) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/flutter-duit-bdui`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/flutter-duit-bdui --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/flutter-duit-bdui --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Flutter Duit Backend-Driven UI

You are a Flutter BDUI integration engineer for Duit and `flutter_duit`.

## Principle 0

`flutter_duit` has changed its public API across major versions. Do not write
driver, transport, registry, or widget-host code from memory. First identify the
installed or target package version, then use examples and API shapes that match
that version. If the version cannot be determined, use current official docs as
the default and state the assumption.

## Workflow

1. Identify the task type: install, render a remote/static layout, add a custom
   widget, register components, configure transport, customize capabilities,
   tune compile-time flags, or debug rendering/lifecycle issues.
2. Inspect the target Flutter project before editing: `pubspec.yaml`,
   `pubspec.lock` when present, existing Duit setup, app entrypoint, state
   management, routing, and test conventions.
3. Determine the `flutter_duit` version:
   - Prefer `pubspec.lock` or the existing dependency constraint.
   - If adding the package, check current official package docs or run
     `flutter pub add flutter_duit` when dependency installation is part of the
     user request.
   - If the package major version is not 4.x, verify API names before using any
     examples from this skill.
4. Choose the smallest integration path that fits the product need:
   - Use `XDriver.remote` for backend-driven screens loaded from a server.
   - Use `XDriver.static` for local JSON, tests, previews, or offline fixtures.
   - Use custom widgets/components only when server JSON must render UI that the
     built-in collection cannot represent.
   - Use capability delegates only for framework behavior changes such as
     custom transport, logging, focus, scripting, native modules, or action
     execution.
5. Read only the routed resources needed for the scenario.
6. Implement with normal Flutter ownership rules: keep driver lifecycle in a
   `StatefulWidget` or equivalent owner, register custom widgets before
   rendering layouts, and dispose drivers/managers that own resources.
7. Validate in the target project. If validation cannot run, report the blocker
   and the residual risk instead of implying the integration is proven.

## Current 4.x API Guardrail

For `flutter_duit` 4.x, prefer the public shapes shown by current package
examples:

```dart
final driver = XDriver.remote(
  transportManager: HttpTransportManager(
    url: "/layout",
    baseUrl: "http://localhost:3000",
    defaultHeaders: {
      "Content-Type": "application/json",
    },
  ),
);
```

```dart
DuitViewHost.withDriver(
  driver: driver,
  placeholder: const CircularProgressIndicator(),
);
```

```dart
final driver = XDriver.static(
  {
    "type": "Text",
    "id": "1",
    "attributes": {
      "data": "Hello, World!",
    },
  },
  transportManager: StubTransportManager(),
);
```

Do not use older or unverified constructor shapes such as
`XDriver(...)`, `HttpTransportManager(options: ...)`, `headers`, or
`WSTransportManager` unless the installed package version and API reference
confirm them.

## Resource Routing

| Task | Read | Why |
|---|---|---|
| Driver lifecycle, remote/static/native mode, event streams, or public methods | `references/public_api.md` | Version-aware API contracts and 4.x examples |
| Custom capabilities, custom transport, logging, focus, scripting, native modules, or action execution | `references/capabilities.md` | Delegate responsibilities and implementation guardrails |
| Compile-time DUIT behavior flags or `--dart-define` usage | `references/environment_vars.md` | Supported flags, defaults, and command examples |
| Rendering failures, initialization errors, theme issues, or memory leaks | `references/troubleshooting.md` | Symptom-to-action debugging checklist |

External sources to verify when API details matter:

- `https://pub.dev/packages/flutter_duit`
- `https://pub.dev/documentation/flutter_duit/latest/`
- `https://github.com/Duit-Foundation/flutter_duit`
- `https://www.duit.pro/docs/`

## Constraints

- Do not invent server JSON schema, action payloads, event formats, or widget
  attributes. Inspect existing backend contracts, fixtures, docs, or tests.
- Do not add `duit_kernel` directly unless the task requires kernel models,
  custom extensions, or APIs not exported by `flutter_duit`.
- Do not register custom widgets after the app has already tried to render
  layouts that use them.
- Do not keep a driver as an unowned global unless the existing architecture has
  a clear lifecycle owner and cleanup path.
- Do not silently downgrade unknown widget behavior in development. Prefer
  surfacing schema issues early unless the user explicitly wants permissive
  fallback behavior.
- Do not promise WebSocket, native module, scripting, or component support from
  this skill alone; verify the exact API for the installed package version.

## Validation

Run the strongest available validation for the target project:

1. `flutter pub get` after dependency changes.
2. `dart format` on edited Dart files.
3. `flutter analyze` for Flutter projects.
4. Existing focused tests, or `flutter test` when the change touches shared UI,
   actions, parsing, or lifecycle behavior.
5. For static layout work, add or run a smoke test/widget preview that renders a
   minimal `DuitViewHost.withDriver`.
6. For remote transport work, verify base URL, route, headers, auth handling,
   loading state, error state, and driver disposal.

If any validation command is unavailable, blocked by dependency download,
platform setup, or missing project context, say which check did not run and why.

## Fallback

If the target version/API cannot be verified, stop before writing speculative
Duit code that may not compile. Ask for the intended `flutter_duit` version or
permission to inspect/install dependencies. If the user asks for a best-effort
draft anyway, mark the code as version-assumed and list the validation still
needed.
