Sitemap

INTRODUCTION TO DART PROGRAMMING LANGUAGE.

--

This article tends to introduce a dart newbie to some of the most common terms and topics in dart programming language. It is the week two assignment of my flutter training program with theStartupIntern , do check up thier site for more information.

Press enter or click to view image in full size
Photo by Gabriel Heinzer on Unsplash

What is Dart?

Dart is a programming language designed for client development, such as for the web and mobile apps. It is developed by Google and can also be used to build server and desktop applications.

Dart is the language used to build flutter applications.

Where and how to learn Dart

The best way to learn the dart programming language is by writing console applications. Dart console applications can be written with ease using an IDE such as VS code and installing the dart extension .

  • Install the Dart extension in your IDE
  • In VS code, hit F1, Select New dart project
  • Activate StageHead
  • Select simply dart console application
  • Pick a suitable name for your project.

Dart Topics to Cover in this Article:

(1) Variables and Data types.

(2) Functions

(3) Conditonals / Decision making statements

(4) Mathematical operations

(5) Logical operators

(6) Brief intro to OOP.

What is a variable and what are data types?

In programming, a variable is a value that can change, depending on conditions or on information passed to the program. It is a named piece of computer memory, containing some information inside.

A data type, in programming, is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error.

examples of data types include :

String : Usually used to represent alphabets but can hold anything inside quotation marks eg “Mark” , “123” , “hd9,v.”

int : This is used to represent whole number integers.

bool: This is used to represent either false or true.

double : This is used to represent decimal numbers, it is a super set of int.

Initializing variables in dart

The first thing to do while initializing variables in dart is to specify the data-type, then the name and equate it to the value using an = sign, it is then closed by ending with a semi-colon. This is shown below:

String myName = “Tochukwu”;

int number = 1;

bool isTrue = true;

What are Functions?

A function is simply a “chunk” of code that you can use over and over again, rather than writing it out multiple times. Functions are usually used to do specific tasks or functions easily.

eg.

Function printName(){

debugPrint(“Tochukwu”);

}

The function above simply prints Tochukwu to the console.

Conditionals / Decision making statements

Decision-making statements are those statements which allow the programmers to decide which statement should run in different conditions.

Get Ezeoke Tochi’s stories in your inbox

Join Medium for free to get updates from this writer.

Conditions include

  • if else,
  • while, etc.

eg .

if (condition) {

//command to run if condition is true

} else {

//command to run if condition is false

}

The other conditionals are similar.

Mathematical operators

Dart uses mathematical operators to perform mathematical operations such as addition, subtraction, mulitplication, division, modulus etc.

These operators include but not limited to

  • (+) for addition
  • (-) for subtraction
  • (/) for division
  • (%) for modulus
  • (*) for multiplication

etc.

Logical operators

Logical operators are used to combine two or more conditions. Logical operators return a Boolean value.

They include,

  • OR (||)
  • AND (&&)
  • NOT (!)

OR logical operator returns true if any of the conditions are true, it returns false when both conditions are false, eg

false || false = false

false || true = true

true || true = true

AND logical operator returns true only when the both conditons are true , it returns false when any of the condition is false. eg

true && true = true

false && true = false

NOT logical operator basically negates the bool it acts on, thus:

!true = false

!false = true

Object Oriented Programming

Press enter or click to view image in full size
Photo by Mohammad Rahmani on Unsplash

Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic.

Dart is an object-oriented language. It supports object-oriented programming features like classes, interfaces, objects etc.

For deeper knowledge, use this youtube video introToDart .

regards,

Tochukwu.

--

--