Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a List<int> into a String in Dart?

Tags:

dart

I have read a file and got myself a list of integers. For most of my work this is what I want to get, but in one case I also need to convert some of List<int> into a String.

To be more specified, I want to encode the string in UTF-8.

This is what I just tried:

var decoder = new Utf8Decoder(figures);
print(decoder.decodeRest());

But all I get is a list of integers.

like image 718
Tower Avatar asked Jul 29 '12 15:07

Tower


People also ask

How do you convert a list to a string in darts?

Create a list named colors . List<String> colors = ['Blue', 'Red', 'Black', 'Yellow', 'White', 'Pink']; Then, convert the List colors to a JSON string using the dart:convert library's built-in jsonEncode() function. String jsonColors = jsonEncode(colors);

How do you convert int to string in darts?

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(). To specify the number of significant digits in the string, use toStringAsPrecision(): // Convert an int to a string.

How do you turn list of objects to list of string in flutter?

We have 3 steps to convert an Object/List to JSON string: create the class. create toJson() method which returns a JSON object that has key/value pairs corresponding to all fields of the class. get JSON string from JSON object/List using jsonEncode() function.


1 Answers

String.fromCharCodes(List<int> charCodes) is probably what you're looking for.

  List<int> charCodes = const [97, 98, 99, 100];
  print(new String.fromCharCodes(charCodes));
like image 115
Alex Avatar answered Oct 20 '22 02:10

Alex