Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert ascii value in integer to its character equivalent in flutter?

I am new to flutter and I just want to display a list of alphabets in a for loop. I just want to know how can I convert the integer to ascii character. I searched for this and I found dart:convert library, but I don't know how to use it.

I want something like -

for(int i=65; i<=90; i++){
print(ascii(i));    //ascii is not any method, its just to understand my question
}

It should print the letters from 'A' to 'Z'.

like image 750
Keshav Avatar asked Nov 13 '18 06:11

Keshav


People also ask

How do you change ASCII to character?

To convert ASCII code to a character, you can use different methods such as Type Casting, toString() method, and toChars() method of the Character class. The toString() method will return a character as a String, while the toChars() method returns the array of characters.

How do you convert int to text in flutter?

Use the toString() method to convert an int or double to a string. To specify the number of digits to the right of the decimal, use toStringAsFixed().

Which function we use to convert a character into its ASCII equivalent?

Using the chr () function, the character that represents the corresponding ASCII code can be obtained.

How would you convert a character to its ASCII integer code?

Here are few methods in different programming languages to print ASCII value of a given character : Python code using ord function : ord() : It converts the given string of length one, returns an integer representing the Unicode code point of the character. For example, ord('a') returns the integer 97.


1 Answers

You don't need dart:convert, you can just use String.fromCharCode

 print(String.fromCharCode(i));

More info: https://api.dartlang.org/stable/2.0.0/dart-core/String/String.fromCharCode.html

like image 124
diegoveloper Avatar answered Sep 20 '22 11:09

diegoveloper