isName function

bool isName(
  1. String name
)

validate the name firstName

it takes name of type string to validate it must contains first name only without spaces symbols etc

the name must be higher than 2 chars

isName("muhamed") == true
isName("mo khaled") == false

Implementation

bool isName(String name) {
  final nameRegex = RegExp(r"^([a-zA-Z]{2,})$");
  return nameRegex.hasMatch(name);
}