to-flutter
This parser helps you generate a Flutter theme from all your design tokens coming from Specify.
Interface
interface parser {
name: 'to-flutter';
output: {
type: 'file';
filePath: string;
};
options?:{
tokenNameTemplate?: string;
}
}
Options
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
|
|
|
| The template the parser follows to name your tokens.
You can use the |
Basic usage
{
"colors": {
"$collection": {
"$modes": [
"light",
"dark"
]
},
"aliases": {
"border": {
"active": {
"$type": "color",
"$value": {
"dark": {
"$alias": "colors.core.label.blue-base",
"$mode": "dark"
},
"light": {
"$alias": "colors.core.label.blue-base",
"$mode": "light"
}
}
}
}
},
"core": {
"label": {
"blue-base": {
"$type": "color",
"$value": {
"dark": {
"model": "rgb",
"red": 96,
"green": 168,
"blue": 250,
"alpha": 1
},
"light": {
"model": "rgb",
"red": 17,
"green": 125,
"blue": 249,
"alpha": 1
}
}
},
"blue-lighter": {
"$type": "color",
"$value": {
"dark": {
"model": "rgb",
"red": 41,
"green": 52,
"blue": 67,
"alpha": 1
},
"light": {
"model": "rgb",
"red": 219,
"green": 236,
"blue": 254,
"alpha": 1
}
}
}
}
}
},
"dimensions": {
"$collection": {
"$modes": [
"desktop",
"mobile"
]
},
"base": {
"dimension-01": {
"$type": "dimension",
"$value": {
"mobile": {
"value": 2,
"unit": "px"
},
"desktop": {
"value": 4,
"unit": "px"
}
}
},
"dimension-02": {
"$type": "dimension",
"$value": {
"mobile": {
"value": 4,
"unit": "px"
},
"desktop": {
"value": 8,
"unit": "px"
}
}
}
}
}
}
.specifyrc.json
{
"version": "2",
"repository": "@organization/repository",
// Only use the personalAccessToken when working with the CLI
"personalAccessToken": "<your-personal-access-token>",
"rules": [
{
"name": "To Flutter",
"parsers": [
{
"name": "to-flutter",
"output": {
"type": "file",
"filePath": "public/tokens.dart"
}
}
]
}
]
}
output/assets/icons/menu.tsx
// ignore_for_file: camel_case_types
import 'dart:core';
import 'package:flutter/painting.dart';
import 'package:flutter/animation.dart';
class Color_ {
static const colorsCoreLabelBlueBaseDark = Color.fromRGBO(96, 250, 168, 1.0);
static const colorsCoreLabelBlueBaseLight = Color.fromRGBO(17, 249, 125, 1.0);
static const colorsAliasesBorderActiveDark = Color.fromRGBO(96, 250, 168, 1.0);
static const colorsAliasesBorderActiveLight = Color.fromRGBO(17, 249, 125, 1.0);
static const colorsCoreLabelBlueLighterDark = Color.fromRGBO(41, 67, 52, 1.0);
static const colorsCoreLabelBlueLighterLight = Color.fromRGBO(219, 254, 236, 1.0);
}
class Dimension_ {
static const dimensionsBaseDimension_01Desktop = 4;
static const dimensionsBaseDimension_01Mobile = 2;
static const dimensionsBaseDimension_02Desktop = 8;
static const dimensionsBaseDimension_02Mobile = 4;
}
Last updated