output property
String
get
output
Returns the generated token themes code. (tokens.g.dart)
Implementation
String get output {
final interfaces = <String>[];
final classes = <String>[];
final interFaceNames = <String, String>{};
for (final transformer in themes.first.transformers) {
interfaces.add(transformer.interfaceDeclaration());
interFaceNames[transformer.name] = transformer.className;
}
final iTokenInterface = '''
abstract class ITokens {
${interFaceNames.entries.map((e) => '${e.value} get ${e.key};').join('\n ')}
}''';
interfaces.insert(0, iTokenInterface);
for (final theme in themes) {
final properties = <String>[];
final insertAt = classes.length;
for (final transformer in theme.transformers) {
properties.add(transformer.propertyDeclaration(theme.name));
classes.add(transformer.classDeclaration(theme.name));
}
final tokenClass = '''
class ${theme.name.pascalCase}Tokens extends ITokens {
${properties.join('\n ')}
}''';
classes.insert(insertAt, tokenClass);
}
return '''
$_genWarning
library tokens;
import 'package:flutter/material.dart';
part 'tokens_extra.g.dart';
${interfaces.join('\n\n')}
${classes.join('\n\n')}''';
}