isValidPubPackageName function

bool isValidPubPackageName(
  1. String name
)

Returns true when the name is a valid pub package name according to https://dart.dev/tools/pub/pubspec#name

The name should be all lowercase, with underscores to separate words, just_like_this. Use only basic Latin letters and Arabic digits: a-z0-9_. Also, make sure the name is a valid Dart identifier—that it doesn’t start with digits and isn’t a reserved word (keyword).

Implementation

bool isValidPubPackageName(String name) {
  return _cliNameRegExp.hasMatch(name) && !_keywords.contains(name);
}