build method
Generates the outputs for a given BuildStep.
Implementation
@override
Future<void> build(BuildStep buildStep) async {
// Get the input asset (lib/flywind/flywind.yaml)
final inputId = buildStep.inputId;
log.info('Processing custom token config: ${inputId.path}');
if (!inputId.path.endsWith('flywind.yaml')) {
log.warning('Expected flywind.yaml input, got: ${inputId.path}');
return;
}
final configContent = await buildStep.readAsString(inputId);
log.info('Found flywind.yaml, generating custom tokens...');
// Parse YAML configuration
final config = loadYaml(configContent) as Map<dynamic, dynamic>;
// Generate custom token classes
if (config['extend']?['colors'] != null) {
await _generateCustomColors(buildStep, config);
}
if (config['extend']?['spacing'] != null) {
await _generateCustomSpacing(buildStep, config);
}
if (config['extend']?['radius'] != null) {
await _generateCustomRadius(buildStep, config);
}
if (config['extend']?['text_style'] != null) {
await _generateCustomTextStyle(buildStep, config);
}
if (config['extend']?['font_weight'] != null) {
await _generateCustomFontWeight(buildStep, config);
}
if (config['extend']?['leading'] != null) {
await _generateCustomLeading(buildStep, config);
}
// Generate the main custom tokens file
await _generateCustomTokensFile(buildStep, config);
log.info('Custom token generation completed!');
}