validateVariableName function

bool validateVariableName(
  1. String fileName
)

Validates that the given fileName is alphanumeric (with underscores as spaces), uppercase and does not start with a number.

Implementation

bool validateVariableName(String fileName) {
  final alphabets = RegExp(r'^[A-Z_]+$');
  final alphaNumeric = RegExp(r'^[A-Z0-9_]+$');
  return alphabets.hasMatch(fileName[0]) &&
      alphaNumeric.hasMatch(fileName.substring(1));
}