Dart Tutorials

Dart List runtimeType
Syntax & Examples

Syntax of List.runtimeType

The syntax of List.runtimeType property is:

 Type runtimeType 

This runtimeType property of List a representation of the runtime type of the object.

Return Type

List.runtimeType returns value of type Type.



✐ Examples

1 Get runtime type of a number

In this example,

  1. We create a variable number with a numeric value.
  2. We then use the runtimeType property to get its runtime type.
  3. We print the runtime type to standard output.

Dart Program

void main() {
  var number = 42;
  var type = number.runtimeType;
  print('Runtime type of number: $type');
}

Output

Runtime type of number: int

2 Get runtime type of a character

In this example,

  1. We create a variable character with a character value.
  2. We then use the runtimeType property to get its runtime type.
  3. We print the runtime type to standard output.

Dart Program

void main() {
  var character = 'A';
  var type = character.runtimeType;
  print('Runtime type of character: $type');
}

Output

Runtime type of character: String

3 Get runtime type of a list

In this example,

  1. We create a variable list containing integers.
  2. We then use the runtimeType property to get its runtime type.
  3. We print the runtime type to standard output.

Dart Program

void main() {
  var list = [1, 2, 3];
  var type = list.runtimeType;
  print('Runtime type of list: $type');
}

Output

Runtime type of list: List<int>

Summary

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.