The syntax of String.runtimeType property is:
Type runtimeType
This runtimeType property of String returns the representation of the runtime type of the object.
String.runtimeType returns value of type Type
.
In this example,
str1
with the value 'Hello, world!'.runtimeType
property of str1
to get its runtime type.str1
is printed to standard output.void main() {
String str1 = 'Hello, world!';
Type type1 = str1.runtimeType;
print('Runtime type of str1: $type1');
}
Runtime type of str1: String
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.