flutter_mcp_ui_core

Core models, constants, and utilities for the Flutter MCP UI system. Shared foundation for the renderer and generator packages, implementing the MCP UI DSL 1.4 specification.

Features

  • Shared data models — UI definitions, widgets, actions, bindings.
  • Material 3 theme systemThemeDefinition mirrors the canonical 14-token-domain spec (color, typography, spacing, shape, elevation, motion, density, breakpoints, border, opacity, focus ring, z-index, components) with optional light/dark overrides.
  • M3 28-role color + 6 semantic roles, surface tonal scale, HCT seed palettes.
  • 15-role typography, 9-step spacing on the 8pt grid, 7-family shapes, 6-level elevation, M3 state-layer opacities.
  • DTCG (W3C Design Tokens) codec — ThemeDefinition.toDtcg() / fromDtcg() for round-trip with Tokens Studio, Style Dictionary, Claude Design exports.
  • Type-safe constants — widget types and property keys.
  • Validation framework — schema, references, and theme validators.
  • Utilities — JSON manipulation, type conversion, property helpers.
  • Structured exceptions for clear error reporting.
  • DSL version management — compatibility checks and migration utilities.

Quick Start

import 'package:flutter_mcp_ui_core/flutter_mcp_ui_core.dart';

// Themes round-trip through the W3C DTCG interchange format (spec §5b).
final theme = ThemeDefinition.defaultLight(seedHex: '#6750A4');
final dtcg = theme.toDtcg();
final restored = ThemeDefinition.fromDtcg(dtcg);

// Widget subtrees are built from the canonical type constants, so a typo is
// a compile error rather than a widget that silently fails to render.
final layout = WidgetConfig(
  type: WidgetTypes.linear,
  properties: {'direction': 'vertical'},
  children: [
    WidgetConfig(type: WidgetTypes.text, properties: {'content': 'Hello'}),
  ],
);

Support

License

MIT — see LICENSE.

Libraries

flutter_mcp_ui_core
Flutter MCP UI Core