Table of Contents

  1. What is Dart?
  2. Hello World in Dart Programming Language
  3. Variables in Dart Programming Language
    • Integer in Dart Programming Language
    • Double in Dart Programming Language
    • Strings in Dart Programming Language
    • Boolean in Dart Programming Language
  4. If & If/Else in Dart Programming Language
  5. Functions in Dart Programming Language
  6. What next?
  7. Additonal Resources

What is Dart?

On any platform, Dart is a client-optimized language for creating quick apps. With a configurable execution runtime platform for app frameworks, it aims to provide the most productive programming language for cross-platform development.

Technical choices made during development that shape a language’s capabilities and strengths are what define a language’s technical envelope. Dart prioritises development (sub-second stateful hot reload) and high-quality production experiences across a number of compilation targets because it is built for a technological envelope that is particularly suited to client development (web, mobile, and desktop).

Dart is the basis for Flutter as well. Flutter apps are powered by the language and runtimes provided by Dart, but Dart also offers a number of essential developer chores like code formatting, analysis, and testing.

Hello World in Dart Programming Language

In this blog, I will be using the editor available at DartPad.

Let’s write the traditional Hello World program like below –

void main(){
 print('Hello World');
}

Now if you select the Run option, you will find Hello World in the console as output.

Variables in Dart Programming Language

Today, I will be discussing about mainly four types of variables and how they can be used in a very simple way

  • Integer
  • Double
  • Strings
  • Boolean

Integer in Dart Programming Language

Here is the program to demonstrate how Integers are being used in Dart programming language

void main() {
 int noOfEmp = 100;
 print('Number of employee: $noOfEmp');
}

Output will be Number of employee: 100

Double in Dart Programming Language

Here is the program to demonstrate how Doubles are being used in Dart programming language

void main() {
 double pie = 3.142;
 print('Value of Pie: $pie');
}

Output will be Value of Pie: 3.142

Strings in Dart Programming Language

Here is the program to demonstrate how Strings are being used in Dart programming language

void main() {
 String websiteName = "Technical Potpourri";
 print('Website Name: $websiteName');
}

Output will be Website Name: Technical Potpourri

Booleans in Dart Programming Language

Here is the program to demonstrate how Booleans are being used in Dart programming language

void main() {
 bool doYouLikeDart = true;
 print('Like Dart? $doYouLikeDart');
}

Output will be Like Dart? true

If & If/Else Statement in Dart Programming Language

Here is the program to demonstrate the usage of If statement.

void main() {
 bool doYouLikeDart = true;
 if(doYouLikeDart){
 print('Yes I like Dart');
 }
}

Output will be Yes I like Dart

Here is the program to demonstrate the usage of If/Else statement.

void main() {
 bool doYouHateDart = false;
 if(doYouHateDart){
 print('Yes I hate Dart');
 }else{
 print('No, I do not hate Dart');
 }
}

Output will be No, I do not hate Dart

Functions in Dart Programming Language

Here is the program to demonstrate the use of functions without parameters.

void main() {
 bool doYouLikeDart = doYouLikeDartFunc();
 if(doYouLikeDart){
 print('Yes I like Dart');
 }else{
 print('No, I do not like Dart');
 }
}
bool doYouLikeDartFunc(){
 bool likeDart = true;
 return likeDart;
}

Output will be Yes, I like Dart

Here is the program to demonstrate the use of functions withour parameters.

void main() {
 bool doYouLikeDart = doYouLikeDartFunc("yes");
 if(doYouLikeDart){
 print('Yes I like Dart');
 }else{
 print('No, I do not like Dart');
 }
}
bool doYouLikeDartFunc(String value){
 bool likeDart;
 if(value == "yes"){
 likeDart = true;
 }else{
 likeDart = false;
 }
 return likeDart;
}

Output will be Yes, I like Dart

What next?

I hope this blog post will give you the basic idea about this programming language. In the coming days, I will be publishing more advanced contents on this programming language. Till then, please provide your feedback in the comment section of this post.

Additional Resources

Disclaimer

This article is not endorsed by any company in any way. I shared my knowledge on this topic in this blog post. Please refer to Official Help for the latest information.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *