Skip to content

Instantly share code, notes, and snippets.

@abdorll
Last active October 11, 2023 20:16
Show Gist options
  • Save abdorll/408accb50320ed2c83584ee54fa39f28 to your computer and use it in GitHub Desktop.
Save abdorll/408accb50320ed2c83584ee54fa39f28 to your computer and use it in GitHub Desktop.
void main() {
// ==================BASIC USAGE
// A bool variable can have two values: true or false.
bool isDartFun = true;
bool isProgrammingEasy = false;
bool isRaining = false;
bool isSunny = true;
// ==================BOOLEAN PROPERTIES
// 1. hashCode → int (The hash code for this object)
int hashCodeValue = isDartFun.hashCode;
// 2. runtimeType → Type (A representation of the runtime type of the object)
Type boolType = isDartFun.runtimeType;
// ==================BOOLEAN METHODS
// 1. toString() → String (Returns either "true" for true and "false" for false)
String boolString = isDartFun.toString(); // Outputs "true" for true
// ==================BOOLEAN OPERATORS
// 1. & (Logical AND): Returns true if both conditions are true.
bool andResult = (isDartFun & isProgrammingEasy);
// 2. == (Equality Operator): Checks if two boolean values are equal.
bool isEqual = isDartFun == isProgrammingEasy;
// 3. | (Logical OR): Returns true if at least one condition is true.
bool orResult = isDartFun | isProgrammingEasy;
// 5. ! Logical NOT (!): Negates the boolean value.
bool rainedThisYear = !isRaining;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment