Dart Tutorial-0: Introduction to Dart(Introduction & Main Method)

Dart is a programming language developed by google. Dart is the language that is used by flutter API and hence, the need to learn dart increases.

Installation:

For installation refer to the following link-https://dart.dev/get-dart.

Main Method

In dart, just like c or c++, we are required to write main method. Every time you will run the dart application, the compiler will check for main( ) method in the dart application.

For example : When you execute the following statement in your console,

$dart my_application

The compiler will search for function named as main( ), if found it’ll execute the function else it’ll print the error on the console.

In dart, main method can be defined in the following ways:-

Program -1

Main() method which takes no command line arguments.

void main( ){

print(“My first dart application”);

}

Program-2

Main method which takes command line argument

void main(List<String> argument){

print(“main function which can take argument”);

}

Important Concepts of Dart

  • Dart is highly Object — Oriented Programming Language. Everything is an object. Be it, a variable or function they all are an object. Function is an object of Function Class.
  • Dart has an unique type called “dynamic” or Object. It gives the user the ability to change the type of object as well as the value of the object.
  • Dart, doesn’t have keywords such as public, protected or private. For making any property of the class as private , the name of the property must start with underscore( _privatePropertyName).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store