Home > Net >  Flutter, how can I write desired function with dart?
Flutter, how can I write desired function with dart?

Time:12-21

I want to print an error message if a letter comes after the first two letters in the following expression.

EN545454545

CodePudding user response:

You can try using the tryParse method of num, if it fails parsing it returns null which means it contained some illegal characters

  String code = 'EN545454545';
  if (num.tryParse(code.substring(2)) == null) {
    // Handle error
  }
  • Related