How to check if a string only contains letters, numbers, underscores and period. Flutter/Dart

I want to check if a string only contains:

  1. Letters
  2. Numbers
  3. Underscores
  4. Periods

in Flutter, I tried the following to get only the letters but even if other characters are there it returns true if it contains a letter:

String mainString = "abc123";

print(mainString.contains(new RegExp(r'(a-z)')));

Is there a way to do that?