Dart double runtimeType
Syntax & Examples
double.runtimeType property
The `runtimeType` property in Dart represents the runtime type of an object.
Syntax of double.runtimeType
The syntax of double.runtimeType property is:
Type runtimeType
This runtimeType property of double a representation of the runtime type of the object.
Return Type
double.runtimeType returns value of type Type
.
✐ Examples
1 Get the runtime type of a string
In this example,
- We create a string
str
with the value 'Hello'. - We use the
runtimeType
property to get its runtime type. - We then print the runtime type to standard output.
Dart Program
void main() {
String str = 'Hello';
Type type = str.runtimeType;
print('Runtime type of $str: $type');
}
Output
Runtime type of Hello: String
2 Get the runtime type of an integer
In this example,
- We create an integer variable
number
with the value 42. - We use the
runtimeType
property to get its runtime type. - We then print the runtime type to standard output.
Dart Program
void main() {
int number = 42;
Type type = number.runtimeType;
print('Runtime type of $number: $type');
}
Output
Runtime type of 42: int
3 Get the runtime type of a list
In this example,
- We create a list of integers
numbers
. - We use the
runtimeType
property to get its runtime type. - We then print the runtime type to standard output.
Dart Program
void main() {
List<int> numbers = [1, 2, 3];
Type type = numbers.runtimeType;
print('Runtime type of numbers list: $type');
}
Output
Runtime type of numbers list: List<int>
Summary
In this Dart tutorial, we learned about runtimeType property of double: the syntax and few working examples with output and detailed explanation for each example.