Dart String runtimeType
Syntax & Examples

Syntax of String.runtimeType

The syntax of String.runtimeType property is:

 Type runtimeType 

This runtimeType property of String returns the representation of the runtime type of the object.

Return Type

String.runtimeType returns value of type Type.



✐ Example

1 Get runtime type of a string

In this example,

  1. We create a string str1 with the value 'Hello, world!'.
  2. We then access the runtimeType property of str1 to get its runtime type.
  3. The runtime type of str1 is printed to standard output.

Dart Program

void main() {
  String str1 = 'Hello, world!';
  Type type1 = str1.runtimeType;
  print('Runtime type of str1: $type1');
}

Output

Runtime type of str1: String

Summary

In this Dart tutorial, we learned about runtimeType property of String: the syntax and few working examples with output and detailed explanation for each example.