convertVarName function

String convertVarName(
  1. String filePath
)

转换文件名为驼峰命名

字符工具包 https://pub.dev/packages/basic_utils#cryptoutils

Implementation

String convertVarName(String filePath) {
  var res;
  var fragments = Path.basename(filePath).split(RegExp(r"[\.\-\_ \&\#+]"));
  var firstWord = fragments[0];
  res = firstWord +
      fragments
          .sublist(1)
          .map((element) {
            if (StringUtils.isAscii(element)) {
              return StringUtils.capitalize(element);
            } else {
              return CryptoUtils.getMd5ThumbprintFromBytes(utf8.encode(element));
            }
          })
          .toList()
          .join();
  return res;
}