Solved: Get number of certain place of long number

Question

Asked by SOS v on January 07, 2022 (source).

How can I get a number of a certain place, for example, when I have a number like 12345, I need the number on the second place, so in this case the 2. A few more examples that you get the idea:

346775 => 4

673456 => 7

099784 => 9

How is this possible in Dart/Flutter?

Answer

Question answered by Victor E (source).

You can convert the number to a String and get the element at index 1 from the String.

void main() {
  final int longNumber = 12345;  
  final int numberAtSecondPlace = int.parse(longNumber.toString()[1]);
  
  print(numberAtSecondPlace); //2
}
DART FLUTTER INTEGER
SHARE: