The `toList` method in Dart creates a List containing the elements of the Iterable.
The syntax of Runes.toList() method is:
List<int> toList({bool growable: true })
This toList() method of Runes creates a List containing the elements of this Iterable.
Parameter | Optional/Required | Description |
---|---|---|
growable | optional | A boolean value indicating whether the list is growable or not. Defaults to true if not provided. |
Runes.toList() returns value of type List<int>
.
In this example,
runes
from the string 'Hello'.toList
method to convert the runes into a List of integers.void main() {
Runes runes = Runes('Hello');
List<int> runeList = runes.toList();
print('Rune list: $runeList');
}
Rune list: [72, 101, 108, 108, 111]
In this example,
numbers
from the string '12345'.toList
method to convert the numbers into a List of integers.void main() {
Runes numbers = Runes('12345');
List<int> numberList = numbers.toList();
print('Number list: $numberList');
}
Number list: [49, 50, 51, 52, 53]
In this Dart tutorial, we learned about toList() method of Runes: the syntax and few working examples with output and detailed explanation for each example.