• Guides
    • Getting started with Dart
  • Blog
  • FAQ
    • Dart
    • Flutter
  • Contact
  • Guides
    • Getting started with Dart
  • Blog
  • FAQ
    • Dart
    • Flutter
  • Contact
  • Getting Started with Dart
    • Dart Variables
    • Dart Operators
    • Dart Comments
  • Dart Data Types
    • Dart Strings
    • Dart Numbers
    • Dart Booleans
    • Dart Lists
    • Dart Maps
  • Control Flow
    • Dart if...else Statements
    • Dart switch Statement
    • Dart for Loop
    • Dart for...in Loop
    • Dart while and do...while Loops
    • break and continue Statements
  • Dart Functions
  • Dart Classes
  • Dart Objects
  • Dart Constructors
  • Dart Exceptions

Dart Booleans

107 views 1

Written by Ajaya Shrestha
December 31, 2021

In this chapter, we will learn about dart booleans data types.


Dart Booleans

Boolean values represent boolean values, i.e. true and false.

The bool keyword is used to denote boolean values.

The syntax for writing a boolean value is:

bool variable_name = true/false;

For example,

bool isValue = true;
bool count = false;

Let’s see this in the program.

void main() {
bool isValue = true;
bool count = false;

print(isValue);
print(count);
}

Output

true
false

The boolean values are mostly used in decision making and for loop conditions as well.

For example,

void main() {
if(true) {
print("Something");
}
else
print("Other things.");
}

Output

Something

Comparison and Logical Operators give the result as boolean values. For example,

Greater than operator > returns true if the left operand is greater than right operand.

void main() {
print(6 > 4);
}

Output

true

Equal to operator returns true if both operands are equal.

void main() {
print( 9 == 9);
}

Output

true

Logical OR || returns true if either of the operands is true.

void main() {
print(true || false);
}

Output

true

In next chapter, We will learn about Dart Lists.

Was this helpful?

1 Yes  1 No
Related Articles
  • Dart Constructors
  • Dart Exceptions
  • Dart Objects
  • Dart Classes
  • Control Flow
  • Dart Functions
Previously
Dart Numbers
Up Next
Dart Lists
flutter-dev-experts




FLUTTERGUIDE
FlutterGuide is an easy learning guide platform to help you build apps for any screen. The leading Dart/Flutter guides for getting started and become pro.
Guides
  • Getting started with Dart 22
  • Private Documentation 1
Categories
  • Firebase
  • Dart
  • iOS
  • API
  • Bloc
  • Flutter
  • Widgets
  • Mobile
  • State Management
  • Design
  • Animations
  • Flutter Designs
About
About Us
Guides
Blogs
FAQs
Contact
  • Privacy Policy
  • Terms & Conditions
  • Copyright 2022 Fawesome Apps. All Rights Reserved