parseName method

String parseName(
  1. String name
)

Parses the name of the asset file to a valid Dart variable name.

Implementation

String parseName(String name) {
  List<String> words =
      name.replaceAll(RegExp(r'[^a-zA-Z0-9\s]'), '').split(RegExp(r'[_\s]'));
  String result = words[0].toLowerCase();
  for (int i = 1; i < words.length; i++) {
    result += words[i][0].toUpperCase() + words[i].substring(1);
  }
  print(result);
  return result;
}