getIconFontTemp method

dynamic getIconFontTemp (IconFontModel iconFontModel, String className)

Implementation

static getIconFontTemp(IconFontModel iconFontModel, String className) {
  String itemContents = "";
  for (IconFontModelGlyphs glyph in iconFontModel.glyphs) {
    String preName = iconFontModel.cssPrefixText ?? "";
    String iconName = glyph.fontClass;

    itemContents += """
static const IconData  ${formatName("$preName$iconName")}= IconData(0x${glyph.unicode}, fontFamily: _family); //  ${glyph.name}
""";
  }

  String contents = '''
//  This file is automatically generated. DO NOT EDIT, all your changes would be lost.
//  https://pub.dartlang.org/packages/iconfont

import 'package:flutter/material.dart' show IconData;

class $className {
static const String _family = '${iconFontModel.fontFamily}';

$className._();

$itemContents
}
''';

  var formatter = new DartFormatter(pageWidth: 200);

  try {
    contents = formatter.format(contents);
  } on FormatterException catch (ex) {
    print(ex);
  }

  return contents;
}