Boolean Example Program in Dart


This code is also written in the Dart programming language and defines a main() function that demonstrates how to declare and initialize a Boolean variable in Dart. Here's what's happening in this code:

  • bool isTrue=true;: This line declares a Boolean variable isTrue and initializes it with a value of true. In Dart, Boolean values can either be true or false.
  • print(isTrue); : This line outputs the value of isTrue to the console output using the print() function.
  • print(isTrue.runtimeType);: This line uses the runtimeType property to determine the data type of isTrue at runtime and outputs the result to the console output using the print() function. The output should be bool, which is the data type of isTrue.

Overall, this program demonstrates how to declare and initialize a Boolean variable in Dart, and how to check its data type using the runtimeType property.

Source Code

void main(){
   bool isTrue=true;
   print(isTrue);
   print(isTrue.runtimeType);
}
To download raw file Click Here

Output

true
bool