Dart Programming - Type Test Operators



Type test Operators

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

Usage of Type Test Operators

Example - is Operator

void main() { 
   int n = 2; 
   print(n is int); 
} 

Output

It will produce the following output

true 

Example - is! Operator

void main() { 
   double  n = 2.20; 
   var num = n is! int; 
   print(num); 
} 

Output

It will produce the following output

true 
dart_programming_operators.htm
Advertisements