Getting Started with Dart Programming Part 1 || Flutter Tutorial

Updated: Apr 28

In this blog post, we are going to see a quick course of Dart Programming.

Definition of Dart Programming - Dart is open source, general purpose & object oriented programming language with C Style. Dart Programming Language Developed by Google. Dart is strongly typed & inspired by other programming languages like Java, JavaScript. Dart is compiled language. So you cannot execute a code directly it has to passed by compiler & then it will convert into machine code.

It supports all most common concepts of programming languages like classes, interfaces, functions. Dart language doesn't support array directly instead it supports collection which is used to replace the data structures like Array.

First Program in Dart Programming

void main() {  
    print('hello world');  
Output Console
hello world

Data Types in Dart Programming

As we already know, Dart is a strongly typed language. We have to define data type for every data element in Dart Programming. Now we are going to discuss most common data types in Dart Language.

  1. String - String is used to store text, String is used to store group of characters. Syntax String variable_name = "fresherside"

  2. num, int, double - Integer is used for numbers having no decimal places, double is used for number having decimal places. Examples - int variable_name=5; double x=5.55

  3. Boolean - Boolean means simply true or false, One value at a time either true or false. Example - bool variable_name = true;

  4. Object - Object means Object, Like Object of a Class. Example - try_obj =t ry_obj(). Generally in Dart, Everything is an Object like (String, Numbers).

Variables & Functions in Dart Programming -

Firstly Let's talk about variables then later we will move to functions.

var variable_name = 50;
var variable_name2 ="fresherside"

In the above code snippet, you can see the declaration of integer & string in 2 different variables in dart programming language.

Now, Let's talk about functions

Functions are another core feature of any programming language. Functions are a set of statements that performs a specific task. They are organized into the logical blocks of code that are readable, maintainable, and reusable. The function declaration contains the function name, return type, and parameters. The following example explains the function used in Dart programming.

//Function declaration 
num addNumbers(num x, num y) {  
 // Here, we use num as a type because it should work with int and double both. 
 return x + y;  
var price1 = 29.99;  
var price2 = 20.81;  
var total = addNumbers(price1, price2);  
var num1 = 10;  
var num2 = 45;  
var total2 = addNumbers(num1, num2);  

Operators in Dart Programming -

Dart language supports almost all types of operators, If you are already familiar with C or C++ or Java or Python or Any other language, you will understand Dart Operators very easily.

There are different types of operators in Dart Programming Language listed below.

  1. Arithmetic

  2. Equality

  3. Increment & Decrement

  4. Logical Comparison

Design Making & Loops -

The decision-making is a feature that allows you to evaluate a condition before the instructions are executed. The Dart language supports the following types of decision-making statements named below.

  1. If Statement

  2. If- Else Statement

  3. Switch Statement

void main() {   
   var num = 12;   
 if (num % 2 = = 0) {   
      print("Number is Even.");   
   } else {   
      print("Number is Odd.");   

Loops are used to execute a block of code repeatedly until a specified condition becomes true. Dart language supports the following types of loop statements:

  • for


  • while

  • do..while

void main() {   
   var name = ["Peter", "Rinky Ponting", "Abhishek"];   
 for (var prop in name) {   

6 views0 comments

Related Posts

See All
  • 1024px-Telegram_logo.svg
  • download
  • YouTube