flutter/dev/tools/gen_defaults
Qun Cheng c7d4b32fdd
Update the default outline color for OutlinedButton (#138768)
Fix b/311343182

This is to update the default outline for `OutlinedButton`. When the button is focused, the outline color should be primary color.
2023-11-22 20:16:37 +00:00
..
bin Add Card.filled and Card.outlined factory methods (#136229) 2023-11-01 23:29:49 +00:00
data Update Carousel tokens to v0.202 (#137728) 2023-11-02 00:45:23 +00:00
generated Update the default outline color for OutlinedButton (#138768) 2023-11-22 20:16:37 +00:00
lib Update the default outline color for OutlinedButton (#138768) 2023-11-22 20:16:37 +00:00
test Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
pubspec.yaml Move dependency on leak_tracker from dependencies to dev_dependencies in flutter_test. (#137633) 2023-10-31 21:12:52 +00:00
README.md Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
test.json Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00

Token Defaults Generator

Script that generates component theme data defaults based on token data.

Usage

Run this program from the root of the git repository:

dart dev/tools/gen_defaults/bin/gen_defaults.dart [-v]

This updates generated/used_tokens.csv and the various component theme files.

Templates

There is a template file for every component that needs defaults from the token database. These templates are implemented as subclasses of TokenTemplate. This base class provides some utilities and a structure for adding a new block of generated code to the bottom of a given file.

Templates need to override the generate method to provide the generated code block as a string.

See lib/fab_template.dart for an example that generates defaults for the Floating Action Button.

Tokens

Tokens are stored in JSON files in data/, and are sourced from an internal Google database.

template.dart should provide nearly all useful token resolvers (e.g. color, shape, etc.). For special cases in which one shouldn't be defined, use getToken to get the raw token value. The script, through the various revolvers and getToken, validates tokens, keeps track of which tokens are used, and generates generated/used_tokens.csv.