Skip to content

pantoken / platforms/flutter/src / toFlutter

Function: toFlutter()

toFlutter(tokens, options): Promise<string>

Experimental

Emit Flutter Dart for an explicit token IR. Returns the written file path.

Parameters

tokens

readonly Token[]

options

GenerateFlutterOptions

Returns

Promise<string>

Examples

Emit a specific theme's IR

ts
import { toFlutter } from "@pantoken/flutter";
import { byTheme } from "@pantoken/tokens";

const file = await toFlutter(byTheme("canvas"), { outDir: "./lib/tokens" });
// writes ./lib/tokens/pantokens.dart (class PanTokens { … })

Dark mode with SVG icon assets and manifest

ts
import { toFlutter } from "@pantoken/flutter";
import { byTheme } from "@pantoken/tokens";

await toFlutter(byTheme("rebrand"), {
  outDir: "./lib/tokens",
  mode: "dark",
  className: "InstUITokens",
  icons: ["add", "check"], // copies SVGs + writes pantoken_icons.dart
});