flutter/dev/tools/gen_defaults
2022-04-29 14:09:07 -07:00
..
bin Migrate AppBar to Material 3 (#101884) 2022-04-27 12:04:36 -07:00
data Updated tokens to v0.92. (#100599) 2022-03-23 12:10:17 -07:00
lib Update FAB M3 token template class to new naming scheme and fix a typo in card.dart (#102654) 2022-04-29 14:09:07 -07:00
test Prepare dev (minus flutter_gallery) for use_super_parameters (#100516) 2022-03-29 12:52:42 -07:00
pubspec.yaml Bump dwds to 13.1.0 (#101730) 2022-04-11 18:29:14 -07:00
README.md Script to generate widget theme data defaults from the Material token database. (#95370) 2022-01-06 11:15:20 -08:00

Token Defaults Generator

Script that generates widget component theme data defaults based on the Material Token database. These tokens were extracted into a JSON file from an internal Google database.

Usage

Run this program from the root of the git repository:

dart dev/tools/gen_defaults/bin/gen_defaults.dart

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 chunk of generated code to the bottom of a given file.

Templates need to override the generate method to provide the generated code chunk as a string. The tokens are represented as a Map<String, dynamic> that is loaded from data/material-tokens.json. Templates can look up whatever properties are needed in this structure to provide the properties needed for the component.

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