generate static method

String generate({
  1. required Directory source,
  2. required String className,
  3. required List<IconEntity> icons,
})

Implementation

static String generate({
  required Directory source,
  required String className,
  required List<IconEntity> icons,
}) {
  final entries = icons.map((icon) {
    final code = icon.code.toRadixString(16);
    final filename = p.setExtension(icon.name.snakeCase, '.svg');
    final path = p.relative(p.join(source.path, filename));

    return "  0x$code: '$path',";
  });

  var template = _template.replaceAll('%CLASS_NAME%', className);
  template = template.replaceAll('%ICON_MAP%', className.camelCase);

  return template.replaceFirst('%ICON_MAPS%', entries.join('\n'));
}