Assignment operators are used in flutter to assign right side operand value to left side operand. The basic assignment operator in flutter is =(Equal). Equal is assign right side value to left side operand without any modification. There are basically 12 Assignment operators available in Dart including Bitwise operators. So in this tutorial we would learn about List of All Assignment Operators in Dart Flutter with Example Tutorial.
Contents in this project List of All Assignment Operators in Dart Flutter with Example:
S.NO. | Operator Sign | Operator Name |
1 | = | Normal assignment |
2 | += | Addition assignment |
3 | -= | Subtraction assignment |
4 | *= | Multiplication assignment |
5 | /= | Division assignment |
6 | %= | Modulo assignment |
7 | ~/= | Integer division assignment |
8 | >>= | Bitwise shift right assignment |
9 | <<= | Bitwise shift left assignment |
10 | ^= | Bitwise XOR assignment |
11 | &= | Bitwise AND assignment |
12 | |= | Bitwise OR assignment |
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 |
void main() { var a, b; a = 10 ; b = 20 ; a = b ; print(a); a += b ; print(a); a -= b ; print(a); a *= b ; print(a); a /= b ; print(a); a %= b ; print(a); a ~/= b ; print(a); a >>= b ; print(a); a <<= b ; print(a); a ^= b ; print(a); a &= b ; print(a); a |= b ; print(a); } |
Output:
Also Read:
Flutter Error Solution Cannot run with sound null safety, because the following dependencies
Sort Number List in Ascending Descending Order Flutter Dart
For Loop While Loop Do-While Looping Statement in Dart Flutter Example Tutorial
Flutter Dart Add Single Line Multiple Line Comments Syntax Example
How to Call Recurring Function in Flutter Dart Repeat Method