The syntax of List.runtimeType property is:
Type runtimeType
This runtimeType property of List a representation of the runtime type of the object.
List.runtimeType returns value of type Type
.
In this example,
number
with a numeric value.runtimeType
property to get its runtime type.void main() {
var number = 42;
var type = number.runtimeType;
print('Runtime type of number: $type');
}
Runtime type of number: int
In this example,
character
with a character value.runtimeType
property to get its runtime type.void main() {
var character = 'A';
var type = character.runtimeType;
print('Runtime type of character: $type');
}
Runtime type of character: String
In this example,
list
containing integers.runtimeType
property to get its runtime type.void main() {
var list = [1, 2, 3];
var type = list.runtimeType;
print('Runtime type of list: $type');
}
Runtime type of list: List<int>
In this Dart tutorial, we learned about runtimeType property of List: the syntax and few working examples with output and detailed explanation for each example.