utils/identifer library

Functions to deal with dart identifiers.

Including keywords from https://dart.dev/language/keywords which are split into 4 categories:

  1. Contextual keywords, which have meaning only in specific places.
  2. Built-in identifiers.
  3. Limited reserved words.
  4. Reserved words, which can’t be identifiers.

Constants

asynchronyKeywords → const Set<String>
builtinKeywords → const Set<String>
contextualKeywords → const Set<String>
invalidIdentifiers → const Set<String>
List of keywords that can't be used as identifiers.
reservedKeywords → const Set<String>

Functions

convertToIdentifier(String identifer, {String prefix = 'a'}) String
Converts a string to a valid dart identifier. For example, by replacing invalid characters, and ensuring the string is prefixed with a letter or underscore.
isValidIdentifier(String identifer) bool
Returns true if this identifier is valid.
isValidVariableIdentifier(String identifer) bool
Returns true this is a valid variable name, that is, a dart identifier which is not a reserved keyword.