Comparison operators are used to compare two values in programming languages. In Dart there are basically 6 comparison operators are available to compare values. In Comparison operator there are always 2 operands with 1 operator condition. If the given condition is True then it will returns us the True part and if the given condition is False then it will returns us the False part. So in this tutorial we would learn about List of All Comparison Operators in Dart Flutter with Example.
Contents in this project List of All Comparison Operators in Dart Flutter with Example:
S.No. | Operator | Name |
1 | == | Equal Equal To |
2 | != | Not Equal To |
3 | > | Greater Than |
4 | < | Less Than |
5 | >= | Greater Then Equal To |
6 | <= | Less Then Equal To |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
void main() { var a, b; a = 10 ; b = 20 ; if(a == b){ // True Condition Part print('True'); }else{ // False Condition Part print('False'); } if(a != b){ // True Condition Part print('True'); }else{ // False Condition Part print('False'); } if(b > a){ // True Condition Part print('True'); }else{ // False Condition Part print('False'); } if(b < a){ // True Condition Part print('True'); }else{ // False Condition Part print('False'); } if(b >= a){ // True Condition Part print('True'); }else{ // False Condition Part print('False'); } if(b <= a){ // True Condition Part print('True'); }else{ // False Condition Part print('False'); } } |
Output:
Also Read:
Flutter Change StrikeThrough Text Line Color in Android iOS
Manually Add Permissions in AndroidManifest.xml File in Flutter Project
Logical Operators in Dart Flutter with Example
Flutter Solve The parameter 'id' can't have a value of 'null' because of its type Error
Example of Try Catch to Handle Exception in Dart Flutter