In this tutorial you will learn about the Dart Type test operators and its application with practical example.
Dart Type test operators
The Type test operators are used to check type of an object. These operators are handy for checking types at runtime.
Operator | Meaning |
---|---|
is |
True if the object has the specified type |
is! |
False if the object has the specified type |
is Operator
Example:- sdf
1 2 3 4 |
void main() { int num = 5; print(num is int); } |
When you run the above Dart program, you will see following output.
Output:-
1 |
true |
is! Operator
Example:-
1 2 3 4 5 |
void main() { double num = 5.25; var res = num is! int; print(res); } |
When you run the above Dart program, you will see following output.
Output:-
1 |
true |